大家好,我从一个新的Debian wsl发行版开始,并在上面安装了nodejs和npm。
尝试使用以下命令更新到npm的最新版本时:
sudo npm安装npm@latest-g
我在网上看到了一些奇怪的问题,这些问题在wsl上似乎很常见。研究人员给出的唯一答案是,使用以下命令将不安全权限设置为true,似乎可以正常工作,但不能真正解决问题:
npm config设置unsafe perm true
我会避免使用这种方法,并找到一个更干净的方法来解决这个问题。
以下是控制台输出:
####@#####:~$ sudo npm install npm@latest -g
npm ERR! path /usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-
ansi
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' ->
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7'
npm ERR! { [Error: EACCES: permission denied, rename
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' ->
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7']
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, rename
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' ->
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path:
npm ERR! '/usr/lib/node_modules/.staging/npm-
18aca6f9/node_modules/wrap-ansi',
npm ERR! dest: '/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7' },
npm ERR! stack:
npm ERR! "Error: EACCES: permission denied, rename
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' ->
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path:
npm ERR! '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-
ansi',
npm ERR! dest: '/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7' }
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! /root/.npm/_logs/2019-03-15T23_53_32_851Z-debug.log
我按照nodejs网站的文档进行安装,在根模式下使用curl获取node的最后11.x版本的存储库。
提前谢谢!