简体   繁体   English

无法安装 npm 包

[英]Unable to install npm packages

I have to install npm package hence used command - npm install -g <package-name> but it resulted into write access error so I changed permissions as follows with refernce to https://flaviocopes.com/npm-fix-missing-write-access-error/我必须安装 npm 包,因此使用命令 - npm install -g <package-name>但它导致写访问错误,所以我改变了权限如下参考https://flaviocopes.com/npm-fix-missing-write -访问错误/

sudo chown -R $USER /opt/node-v10.22.0-linux-x64/lib/node_modules/

and tried again but if failed again -并再次尝试,但如果再次失败 -

npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/requirejs/bin/r.js
npm ERR! dest /opt/node-v10.22.0-linux-x64/bin/r.js
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/requirejs/bin/r.js' -> '/opt/node-v10.22.0-linux-x64/bin/r.js'
npm ERR!  { [Error: EACCES: permission denied, symlink '../lib/node_modules/requirejs/bin/r.js' -> '/opt/node-v10.22.0-linux-x64/bin/r.js']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, symlink '../lib/node_modules/requirejs/bin/r.js' -> '/opt/node-v10.22.0-linux-x64/bin/r.js'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'symlink',
npm ERR!      path: '../lib/node_modules/requirejs/bin/r.js',
npm ERR!      dest: '/opt/node-v10.22.0-linux-x64/bin/r.js' },
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, symlink \'../lib/node_modules/requirejs/bin/r.js\' -> \'/opt/node-v10.22.0-linux-x64/bin/r.js\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/requirejs/bin/r.js',
npm ERR!   dest: '/opt/node-v10.22.0-linux-x64/bin/r.js' }
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.

also when I run command with sudo , it gives npm not found .同样,当我使用sudo运行命令时,它会给出npm not found Please guide what is wrong here.请指导这里有什么问题。

you need read write permissions to /opt/node-v10.22.0-linux-x64/ as it creates a symlink there for you.您需要 /opt/node-v10.22.0-linux-x64/ 的读写权限,因为它会为您创建一个符号链接。 you can also check the destination in error it clearly says you don't have permission there.您还可以错误地检查目的地,它清楚地表明您在那里没有权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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