简体   繁体   中英

Can't install NPM packages

I am a newbiew, I am using meteor and trying to install this NPM package https://github.com/nkarni/meteor-stock

I generate the install and I get this error:

npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! path /usr/local/lib/node_modules/generator-meteor-stock
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/generator-meteor-stock'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/generator-meteor-stock']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/generator-meteor-stock',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/generator-meteor-stock',
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:46:5

I have the latest versions of Nodejs and NPM installed and this error happens when I try to install any NPM package.

Will appreciate help.

Adam

Thanks all the answers for pointing me in the right direction, it was a permission thing.

I watched and did all that in this video and it works (In case anyone in the future runs into the same problem): https://docs.npmjs.com/getting-started/fixing-npm-permissions

It sounds like you may be installing on the incorrect folder. Verify that you're in the correct folder (cd where your app/project resides) and when installing i'd recommend to use npm install generator-meteor-stock --save that will install it in your project instead of globally.

It seems you are trying to install it globally, so you should use "sudo" for that:

sudo npm install -g generator-meteor-stock

If you want to use it only for your specific project you can install it locally:

npm install generator-meteor-stock

From what i see you have a permission error on writing to directory.

Try to set up the right writing permission to the global or local directory (depending on how do you want to install the npm package: locally or globally, lately using -g argument.

You can change the directory/file access permission with the following command:

sudo chmod -r +x /path/to/directory

or

sudo chmod 777 +x /path/to/directory

You may need to change the user access group to:

sudo chown -R $USER /path/to/local/directory

or if you installed the package globally specify the directory where are node.js packages are installed. If i'm not wrong they are installed in ~/.npm folder.

sudo chown -R $USER ~/.npm

Use with sudo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM