我试着开始一个项目,安装npm install -g pnpm
作为一个要求,我尝试了npm安装,但它确实工作。但npm install -g pnpm
显示错误如下;下面是终端!
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/pnpm/bin/pnpm.cjs
npm ERR! dest /usr/bin/pnpm
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'
npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'] {
npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/pnpm/bin/pnpm.cjs',
npm ERR! dest: '/usr/bin/pnpm'
npm ERR! },
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/pnpm/bin/pnpm.cjs',
npm ERR! dest: '/usr/bin/pnpm'
npm ERR! }
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.
2条答案
按热度按时间3qpi33ja1#
1.备份您的计算机。
1.在命令行上,在主目录中,为全局安装创建一个目录:
1.配置npm以使用新目录路径:
1.在您喜欢的文本编辑器中,打开或创建一个
~/.profile
文件并添加以下行:1.在命令行中,更新系统变量:
1.要测试新配置,请在不使用
sudo
的情况下全局安装一个软件包:来源:https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
yks3o0rb2#
另一种选择是在硬盘上创建一个新分区,或者如果可能的话创建一个全新的驱动器(在Windows操作系统上为D:\或E:\),并按照我们所知道的方式配置项目-隔离安装的软件包。
虽然全球安装很方便,但由于Mac和PC的安全性越来越高,这些EACCES错误总是会出现。