gpt4 book ai didi

node.js - 无法安装 vue-cli,因为 npm 无限循环问题

转载 作者:行者123 更新时间:2023-12-03 06:40:42 26 4
gpt4 key购买 nike

VueJS 的新手,我正在尝试安装 vue-cli,因为我理解这是构建 VueJS 应用程序的最低要求。

我跑:

$ npm install --global vue-cli
Unhandled rejection Error: EACCES: permission denied, open '/Users/myuser/.npm/_cacache/tmp/2e41a7b1'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>

我找到了 this SO answer here建议运行:

$ npm i --no-package-lock
npm WARN saveError ENOENT: no such file or directory, open '/Users/myuser/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/myuser/package.json'
npm WARN myuser No description
npm WARN myuser No repository field.
npm WARN myuser No README data
npm WARN myuser No license field.

up to date in 0.374s
found 0 vulnerabilities



╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.9.0 → 6.14.6 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.14.6 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯

然后我去升级npm:

$ npm install -g npm
Unhandled rejection Error: EACCES: permission denied, open '/Users/myuser/.npm/_cacache/tmp/54213b04'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>

...我又回到了起点!这是怎么回事?!


更新

当我尝试强制清理缓存时,我也会遇到错误:

$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/myuser/.npm/_cacache/content-v2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! [OperationalError: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'] {
npm ERR! cause: [Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: "Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/myuser/.npm/_cacache/content-v2'
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 (though this is not recommended).

关于潜在权限问题的更新

请记住,这是我自己用户的主目录,所以我绝对应该拥有完全访问权限/权限才能使用,并且我已经使用这台笔记本电脑多年,任何问题都没有。

当我 cd 进入 /Users 并运行 ls -al 我得到:

$ ls -al
total 0
drwxr-xr-x 5 root admin 160 Apr 9 2018 .
drwxr-xr-x 30 root wheel 960 May 2 2019 ..
-rw-r--r-- 1 root wheel 0 Jul 15 2017 .localized
drwxrwxrwt 5 root wheel 160 Apr 9 2018 Shared
drwxr-xr-x+ 117 myuser staff 3744 Jul 11 11:14 myuser

所以这不可能是一个实际的权限问题。


尝试卸载 Node 和安装 nvm 的更新

我能够关注 this link从我的系统中手动删除 Node/npm。然后我尝试关注 this link安装 nvm 但它似乎对我不起作用:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11329 100 11329 0 0 33913 0 --:--:-- --:--:-- --:--:-- 34123
=> Downloading nvm from git to '/Users/myuser/.nvm'
=> Cloning into '/Users/myuser/.nvm'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 7748 (delta 0), reused 1 (delta 0), pack-reused 7747
Receiving objects: 100% (7748/7748), 2.63 MiB | 1.77 MiB/s, done.
Resolving deltas: 100% (4905/4905), done.
* (HEAD detached at v0.33.0)
master
=> Compressing and cleaning up git repository
Counting objects: 7748, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7684/7684), done.
Writing objects: 100% (7748/7748), done.
Total 7748 (delta 5188), reused 2329 (delta 0)

=> Appending nvm source string to /Users/myuser/.bashrc
=> bash_completion source string already in /Users/myuser/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="/Users/myuser/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

所以我关闭我的终端并重新启动它然后运行:

$ nvm --version
-bash: nvm: command not found

最佳答案

看起来您没有权限访问该目录:

cd /Users/myuser
chown -R $USER ./.npm

请重试。

如果它不起作用,我建议完全删除您的 nodejs 并安装 nvm 并使用 nvm 安装 nodejs

关于node.js - 无法安装 vue-cli,因为 npm 无限循环问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62843301/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com