search.png
关于我
menu.png
wsl npm install权限问题

在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.com/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 执行成功

版权声明

知识共享许可协议 本文章由作者“衡于墨”创作,转载请注明出处,未经允许禁止用于商业用途

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。
发布时间:2021年08月02日 19:42:22

评论区#

还没有评论哦,期待您的评论!

关闭特效