NPM won't install pug? - node.js

Can anyone help me decipher what this message is about?
I have another app with pug installed, yet now I cannot create a new module installation for some reason.
I'm installing pug local to the app into node_modules
I'm just trying to get work done, so if I have missed something simple, my stress level has not been helpful with keeping precise vision.
My system is for ongoing development so I don't muck around with upgrades, which historically has broken all kinds of other stuff.
My other app works fine.
# npm install --save pug#2.0.0-beta4 <= Because the working app uses this one
npm ERR! Linux 3.2.0-35-generic-pae
npm ERR! argv "/home/kingram/.nvm/v0.10.46/bin/node" "/home/kingram/.nvm/v0.10.46/bin/npm" "install" "--save" "pug#2.0.0-beta4"
npm ERR! node v0.10.46
npm ERR! npm v2.15.1
npm ERR! path /home/kingram/.npm/wordwrap/0.0.2
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! Error: EACCES, mkdir '/home/kingram/.npm/wordwrap/0.0.2'
npm ERR! { [Error: EACCES, mkdir '/home/kingram/.npm/wordwrap/0.0.2']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/kingram/.npm/wordwrap/0.0.2',
npm ERR! parent: 'cliui' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /home/kingram/node/fssreg/npm-debug.log

You may need to install using sudo, ie - sudo npm install .... This will prompt you for your root password.
It looks like root privileges are required to install the package you're looking for. Though this shouldn't really be the case, you can fix this....check out this link

After some prodding by #zillaofthegods, it turns out some of directories in ~/.npm were owned by root. In particular the wordwrap module directory.
Changed the permissions and npm installed it fine.
One of those things I would not have caught without some prodding, so thanks.

Related

What should be done to have permits to join two modules of a project without using sudo?

I am trying to link two modules created by me, in a project created with Node.js, and as always I did: npm link . inside the module that I want to call, and from the other call it in package.json, and it gives me the following error:
npm ERR! path /home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall symlink
npm ERR! Error: EACCES: permission denied, symlink '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db' -> '/usr/lib/node_modules/michaelgram-db'
npm ERR! { Error: EACCES: permission denied, symlink '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db' -> '/usr/lib/node_modules/michaelgram-db'
npm ERR! stack: 'Error: EACCES: permission denied, symlink \'/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db\' -> \'/usr/lib/node_modules/michaelgram-db\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db',
npm ERR! dest: '/usr/lib/node_modules/michaelgram-db' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/miguel/.npm/_logs/2018-07-17T12_02_46_081Z-debug.log
How should I install Node globally?
I have seen those files and they are owned by root. I put a new version of Ubuntu 18.04 I installed node Could it be problem when installing node? I do not remember how I did it, but on previous occasions I did not have this permission problem. I do not know if I should uninstall node and npm I have to install it in a way that I can access from any project I do. I already gave another file problems and I corregi using sudo, but it does not seem like a practice, because it should not give problems, never gave them node. What do you advise me to do to correct the problem and access node_modules without using sudo? Maybe I should uninstall and install it in another way? Thank you, I hope you understand my need, forgive the syntax but I must use the translator. Thank you.
I would advice you the 2 definitive ways given in the npm documenation
1)Reinstall npm with a version manager (recommended)
2)Change npm's default directory manually.
please visit https://docs.npmjs.com/getting-started/fixing-npm-permissions

Can't install any packages to NPM or BOWER

I have researched this extensively and nothing. So I am hoping this generates a different solution.
I keep getting this error
npm WARN packages#1.0.0 No description
npm WARN packages#1.0.0 No repository field.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! path C:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\.staging\depd-974ec5fe
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\.staging\depd-974ec5fe' -> 'C
:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\depd'
npm ERR! at destStatted (C:\Users\Luis\AppData\Roaming\nvm\v6.9.1\node_modules\npm\lib\install\action\finalize.js:25:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\.staging\depd-974ec5fe' -> 'C
:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\depd'
npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\.staging\depd-974ec5fe' ->
'C:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\depd'
npm ERR! at destStatted (C:\Users\Luis\AppData\Roaming\nvm\v6.9.1\node_modules\npm\lib\install\action\finalize.js:25:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\.staging\depd-974ec5fe' -> 'C
:\xampp\htdocs\nodeprojects\contact-list-app\node_modules\depd'
npm ERR! at Error (native) parent: 'packages' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! C:\xampp\htdocs\nodeprojects\contact-list-app\npm-debug.log
It's not a Mac, It's a Windows machine, so nothing to do with sudo as other responses suggested here
I don't have an antivirus running so this was a no-go too
I ran npm cache clean as suggested here and other SO solutions
It was running fine, and then it started doing this when I tried to install angular-ui-bootstrap. but I was able to install other dependencies just fine.
I also did:
Restarted my machine
used CMD as administrator
Used git bash
Used npm console
Deleted the whole thing and started again in another directory ( got desperate)
uninstalled and re-installed node.js
drank a lot of coffee, and upgraded to alcohol
Please bail me out.
I am posting this answer, simply because there isn't enough documentation on this error in the web, but please if you have other ideas you'd like to add as a possible solution (other than the ones I tried in my question) please feel free. I'm sure there are a lot of other frustrated developers looking for this. Anyway, this is how I solved it.
I deleted my node_modules folder just so I can re-install the dependencies fresh. This doesn't break anything in your project because as soon as you add them back up, they will be in the exact same place they were before. So, do n't be afraid of the 404s you will get temporarily.
Then I did a fresh install by running
npm init
This get my packages.json file going
And then I tried to install my first dependency, any dependency, pick one. But the error came up and the node_modules didn't even get started. So I got it running by installing npm in itself as a dependency. Why did this work? Beats me! But the mystic powers of node know something I don't and I am ok with that.
So I did this basically
npm install npm --save
This built my node_modules folder and I was able to install everything back. I removed the npm dependency afterwards and it's like it was never there.
Again, feel free to post any other solutions. I don't think this is a definite solution so I won't mark it. It just worked for me. Thought I shared it
EDIT
DO NOT delete that npm dependency by running npm uninstall <package> as you normally would. Instead, just delete the dependency with a good 'ol delete key

Cannot change npm global location

looks like i messed up something with npm, and i don't know what should i do.
environments:
- Amazon Linux (EC2)
this is the story:
I installed nodejs with yum: "yum install nodejs npm --enablerepo=epel" on my server few months ago.
and then, i knew that there were node version manager(nvm), so i removed my node.js and install the nvm, and then installed latest node.js
but looks like there were something messed up with nvm settings(recently realized) so i removed nodejs with nvm, and then removed nvm.
then i re-installed node.js with same above with yum command. it looks fine, nodejs worked well, but there was big trouble with npm. i checked the location of global modules with command "npm root -g" as normal user(ec2-user), it prints
npm ERR! Error: EACCES, mkdir '/root/.nvm/versions/node/v5.5.0'
npm ERR! { [Error: EACCES, mkdir '/root/.nvm/versions/node/v5.5.0']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/root/.nvm/versions/node/v5.5.0' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 4.1.13-19.31.amzn1.x86_64
npm ERR! command "node" "/usr/bin/npm" "prefix"
npm ERR! cwd /home/ec2-user/modernator
npm ERR! node -v v0.10.42
npm ERR! npm -v 1.3.6
npm ERR! path /root/.nvm/versions/node/v5.5.0
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/root/.nvm/versions/node/v5.5.0'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ec2-user/modernator/npm-debug.log
npm ERR! not ok code 0
so i logged in to admin, and typed same command "npm root -g", it prints:
/usr/lib/node_modules
looks like something is messed up when i removed nvm. everytime i tried to change npm prefix or just try to get any config from npm as normal user, always fail with same error messages!
but if i try with sudo("sudo npm root -g"), it says "/usr/lib/node_modules".
i spend to solve this problem for days but i still working on. and still i don't know even what should i do. every posts found from google not worked. i removed and installed nodejs plenty of times, but not worked. please god, if someone know how to solve this, please give me a advice.
You don't have access by default to root resources.
When you perform this:
npm root -g
It tries it for root user, i bet you need to change user:
npm $USER -g

npm install from git repo fails with ENOENT

I am trying to install one of my own packages as follows
npm install --save gfarrell/state.js
and I'm getting the following errors (full log here):
npm ERR! addLocal Could not install gfarrell/state.js
npm ERR! Error: ENOENT, stat 'gfarrell/state.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "--save" "gfarrell/state.js"
npm ERR! cwd /Users/gideon/Code/PresenceMonitor
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.10
npm ERR! path gfarrell/state.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/gideon/Code/PresenceMonitor/npm-debug.log
npm ERR! not ok code 0
Now I've tried various solutions including:
npm cache clean
sudo npm cache clean
rm -rf ~/.npm
sudo npm install --save gfarrell/state.js
npm install --save git://github.com/gfarrell/state.js.git
but nothing has changed the error output. I can't see anything wrong with the module's package.json, and I haven't added anything to my local package.json either. I actually tried installing this package on an earlier version and it worked fine, so I just don't understand what is going wrong.
Needless to say, it's all rather frustrating. Is there something else going on that I'm just not seeing?
This is most probably an authentication issue. You should add --verbose to the install command to se more output. You should see this line in your console output when running with verbose on:
npm ERR! git clone git#github.com:gfarrell/state.js Permission denied (publickey).
Check if you are authenticated to Github using the following command:
ssh -T git#github.com
When you are authenticated correctly you should see the following output:
Hi gfarrell! You've successfully authenticated, but GitHub does not provide shell access.
Github has a great guide on SSH keys as well as how to solve common errors.
Fix your Github authentication and the npm install will start working.
I had a similar issue myself. Because the last "ok" line of the verbose output started with "addRemoteGit", I traced the issue to a function named addRemoteGit in the npm source file cache.js (in v1.4.9, it has now been moved into add-remote-git.js). By adding a call to log.verbose(p), I found out npm could not write to ~/.npm/_git-remotes/.
Basically it was a permission problem: my ~/.npm directory contained files & directories owned by root. I solved the issue by simply running:
sudo find ~/.npm -exec chown $USER:$USER {} \;

NPM won't install any package on Mac. New, clean build. `EACCES` & other errors

I've just rebuild my Mavericks (Mac OS X Version 9.4) machine from scratch. I am the administrator and only user of this machine.
I installed Git via their git-2.0.1-intel-universal-snow-leopard.pkg (http://git-scm.com/downloads) in their default /usr/local/git/bin/git location.
I installed Node via their node-v0.10.30.pkg (http://nodejs.org/download/) in their default /usr/local/bin/node location.
The final step of Node's installer package included a note that they also installed NPM in their default /usr/local/bin/npm location.
My $PATH echoes /usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin (it contains /usr/local/bin).
Running npm install -g bower results in:
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! cwd /Users/Home
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! fstream_path /usr/local/lib/node_modules/bower
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Home/npm-debug.log
npm ERR! not ok code 0
Running similar installations (npm install -g yo, npm install -g grunt, npm install -g nvm, npm install -g npm) results in what appears to be the same list of errors.
Several people online suggest forcing the installation via sudo, but several others warn this could cause later issues. The manuals for these packages seem not to mention requirement of sudo, and in some cases, they have advised contacting NPM when this issue arises.
Running npm cache clear does not correct the issue.
Running ls -la in the home (~) directory shows my Mac OS X username as the owner of my .npm directory: drwxr-xr-x 15 admin staff 510 Aug 11 23:53 .npm
Does anyone know what has gone wrong and how to correct this? Thank you.
By the way, I solved this issue by changing the owner of /usr/local to be myself, in order to allow NPM to modules in its default location without further requiring sudo for each package's installation.
sudo chown -R `whoami` /usr/local
EACCES is an error of not having access on doing an operation.
Taken the line: npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower' we can see that npm was unable to create a directory in the given location.
The reason is very likely that you are not running the command as super user. In fact, the error log is even suggesting that:
npm ERR! Please try running this command again as root/Administrator.
To run as administrator, you have to prefix those commands with sudo. That is:
sudo npm install -g bower. You will be required to type in a password for security reasons.
to start fresh remove prior node.js and npm installs as well as these :
~/.npmrc
~/.npm
~/tmp
~/.npm-init.js
to install nodejs and npm as yourself NOT root do these commands (linux) :
mkdir ${HOME}/bin
download source from : http://nodejs.org/download/
cd v0.10.30/
./configure --prefix=${HOME}/bin/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${HOME}/bin/nodejs/bin:$PATH
NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules
do above AND use syntax : npm install xxxxx -g
always use the -g for global
nodejs install gives you npm as well :
ls -la ${HOME}/bin/nodejs/bin
I'd recommend that you install Node.js using a version manager such as nvm. This way, you kill two birds with one stone:
First, you can manage multiple versions of Node.js on the same machine (which you will want to do sooner or later).
Second, you get around all the access problems you experience when installing Node.js without it. At least that's my experience.
Basically it's as easy as running
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.24.1/install.sh | bash
from the command line.
(SOLUTION ANSWER)
Hi Guys,
I had the same problem on my MacBook Pro 2018. After trie installing any dependency globally (with "-g" or "--global") I did receive an issue "EACCES" error (it's about permissions)
You could simply add "sudo" before your commands what will force it.
For example:
sudo npm install gulp -g
or
sudo npm install browser-sync -g
Enjoy!
It's generally not advised to run sudo unless absolutely necessary.
For issues like this, NPM can solve many issues, and allow multiple node versions to be used, and selected depending upon your use case.
I had a similar issue setting up a new machine, and installing NPM took care of the issue.

Resources