admin管理员组

文章数量:1558052

在wsl 装cnpm,加快下载包的速度,结果报错:

npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/.staging/npm-1c7703b5/node_modules/yargs-parser
npm ERR! dest /usr/lib/node_modules/.staging/yargs-parser-3f5f2639
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename ‘/usr/lib/node_modules/.staging/npm-1c7703b5/node_modules/yargs-parser’ -> ‘/usr/lib/node_modules/.staging/yargs-parser-3f5f2639’
npm ERR! [OperationalError: EACCES: permission denied, rename ‘/usr/lib/node_modules/.staging/npm-1c7703b5/node_modules/yargs-parser’ -> ‘/usr/lib/node_modules/.staging/yargs-parser-3f5f2639’] {
npm ERR! cause: [Error: EACCES: permission denied, rename ‘/usr/lib/node_modules/.staging/npm-1c7703b5/node_modules/yargs-parser’ -> ‘/usr/lib/node_modules/.staging/yargs-parser-3f5f2639’] {
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘rename’,
npm ERR! path: ‘/usr/lib/node_modules/.staging/npm-1c7703b5/node_modules/yargs-parser’,
npm ERR! dest: ‘/usr/lib/node_modules/.staging/yargs-parser-3f5f2639’
npm ERR! },
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘rename’,
npm ERR! path: ‘/usr/lib/node_modules/.staging/npm-1c7703b5/node_modules/yargs-parser’,
npm ERR! dest: ‘/usr/lib/node_modules/.staging/yargs-parser-3f5f2639’,
npm ERR! parent: ‘cnpm’
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.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-02T11_28_51_891Z-debug.log

下意识觉得是权限不足,sudo npm install -g cnpm试了一下
依然报错

sudo su 之后再次尝试,还是不行。

怀疑是npm 的问题,因为是为了装yarn,索性试一下sudo npm install -g yarn

成功了~

然后就是 yarn add cnpm -g 执行成功

本文标签: 权限WSLnpminstall