Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js WSL Debian尝试更新至最新版本的npm fresh install上的EACCES问题_Node.js_Npm - Fatal编程技术网

Node.js WSL Debian尝试更新至最新版本的npm fresh install上的EACCES问题

Node.js WSL Debian尝试更新至最新版本的npm fresh install上的EACCES问题,node.js,npm,Node.js,Npm,大家好,我从一个全新的Debian wsl发行版开始,在上面安装了nodejs和npm 尝试使用以下命令更新到最新版本的npm时: sudo npm安装npm@latest-g 我在互联网研究中看到一些奇怪的问题,这些问题在wsl上似乎很常见。唯一的答案似乎是可行的,但没有真正正确地解决问题。该问题是使用以下命令将不安全权限设置为true: npm配置设置不安全perm true 我会避免使用这种方法,并找到一种更干净的方法来解决这个问题 以下是控制台输出: ####@#####:~$ sudo

大家好,我从一个全新的Debian wsl发行版开始,在上面安装了nodejs和npm

尝试使用以下命令更新到最新版本的npm时:

sudo npm安装npm@latest-g

我在互联网研究中看到一些奇怪的问题,这些问题在wsl上似乎很常见。唯一的答案似乎是可行的,但没有真正正确地解决问题。该问题是使用以下命令将不安全权限设置为true:

npm配置设置不安全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网站的文档,在root模式下使用curl进行安装,以获取node最后11.x版本的存储库


提前谢谢

在WSL Ubuntu发行版上遇到此问题,并且仅在
重命名上遇到此问题

即使在我的node\u modules目录中使用了
chown
,在
npm update
上也会发生这种情况


我得到的解决方法是简单地避免
update
,而是使用
install
(npm installnpm@x技术上也是一个更新)。我知道这很麻烦,但除此之外,我不知道如何使它工作。重命名目录的命令会触发此操作,但不会在
create
delete

上触发。在我的WSL中,所有全局安装都会突然失败。设置
npm config set unsafe perm true
对我不起作用。您好,事实上,我只在为其他人全局安装npm包时才面临这个问题。我没有任何问题。可能要注意在您的主文件夹中设置npm全局目录。可能来自npm文档的此链接也可以帮助您:谢谢。前几天我试过了,但没有成功。切换到
纱线
,它可以工作,所以我不会抱怨。有时候你只是破坏了npm,你不知道为什么,哈哈。这对我来说不起作用,因为有些项目已经安装了postall操作,这些操作将使用
rename
。@charlybones可能会尝试升级到WSL 2,显然那里有更好的文件IO管理。我没有给自己一个机会,因为在这之后我回到了mac。