代码之家  ›  专栏  ›  技术社区  ›  Guillaume D

试图更新到最新版本的WSL Debian上npm fresh install的EACCES问题

  •  0
  • Guillaume D  · 技术社区  · 5 年前

    大家好,我从一个新的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版本的存储库。

    提前谢谢!

    0 回复  |  直到 5 年前
        1
  •  2
  •   kierrsun    5 年前

    在WSL Ubuntu发行版上遇到此问题,并且仅在 rename .

    也发生在 npm update 即使在使用之后 chown 在我的node_modules目录中。

    我工作的方法就是避免 update 使用 install 相反(npm install npm@x在技术上也是一个更新)。我知道这很麻烦,但除此之外,我不知道如何使它工作。命令 重命名 目录触发此操作,但不在 create delete .