我是初学者,我正在尝试学习Angular,所以我正在尝试使用angular-seed安装一个新项目。但是当我做npm安装时,我得到一个错误,我不知道它来自哪里。我安装了节点。版本是5.5.0。这是我在控制台中遇到的错误。
npm verb install Error: Unsupported npm verb install at checkPlatform (/usr/lib/node_modules/npm/node_modules/npm-install-checks/index.js:46:14) npm verb install at Array. (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8) npm verb install at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14) npm verb install at /usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7 npm verb install at checkEngine (/usr/lib/node_modules/npm/node_modules/npm-install-checks/index.js:25:10) npm verb install at Array. (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8) npm verb install at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14) npm verb install at chain (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5) npm verb install at module.exports.isInstallable (/usr/lib/node_modules/npm/lib/install/validate-args.js:26:3) npm verb install at resolveWithNewModule (/usr/lib/node_modules/npm/lib/install/deps.js:452:12) npm verb lock using /home/david/.npm/_locks/staging-7c9a6a9e85daffeb.lock for /home/david/DiabetesApp/angular-seed/node_modules/.staging npm verb unlock done using /home/david/.npm/_locks/staging-7c9a6a9e85daffeb.lock for /home/david/DiabetesApp/angular-seed/node_modules/.staging npm verb stack Error: EACCES: permission denied, mkdir '/home/david/DiabetesApp/angular-seed/node_modules/.staging' npm verb stack at Error (native) npm verb cwd /home/david/DiabetesApp/angular-seed npm ERR! Linux 3.13.0-76-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--verbose" npm ERR! node v5.5.0 npm ERR! npm v3.3.12 npm ERR! path /home/david/DiabetesApp/angular-seed/node_modules/.staging npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall mkdir npm ERR! Error: EACCES: permission denied, mkdir '/home/david/DiabetesApp/angular-seed/node_modules/.staging' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, mkdir '/home/david/DiabetesApp/angular-seed/node_modules/.staging'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/home/david/DiabetesApp/angular-seed/node_modules/.staging' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm verb exit [ -13, true ] npm ERR! Please include the following file with any support request: npm ERR! /home/david/DiabetesApp/angular-seed/npm-debug.log
答案 0 :(得分:2)
问题:您(用户)没有该目录的正确权限集。
即时出路是使用sudo运行npm安装,但这可能会给你带来同样的错误或安装不当。
解决方案 / 建议:更改npm的默认目录(来自官方docs)
在继续前进之前备份计算机。
(可选)如果您安装错误,请先将其卸载:
npm uninstall <package-name> # use sudo if you used it while installation
npm cache verify # or, npm cache clean for npm version below 5.x.x
为全局安装创建目录:
<强> mkdir ~/.npm-global
强>
配置npm以使用新目录路径:
<强> npm config set prefix '~/.npm-global'
强>
打开或创建~/.profile
或~/.bash_profile
文件并添加以下行:
<强> export PATH=~/.npm-global/bin:$PATH
强>
返回命令行,更新系统变量,或重新启动终端:
<强> source ~/.profile
强>
(可选)测试:在不使用sudo的情况下全局下载包。
<强> npm install -g jshint
强>
答案 1 :(得分:0)
“请尝试以root / Administrator身份再次运行此命令。”
尝试sudo npm install
。
答案 2 :(得分:0)
这是一个权限问题。您必须修复此目录的权限,并在没有sudo的情况下运行npm install
。
cd your_working_directory
sudo chown -R $( whoami ):$( whoami ) .
sudo chmod -R 755 .
npm install
答案 3 :(得分:0)
要避免EACCESS错误,请使用节点版本管理器重新安装node和npm(根据written in npm documentation)。
有关更多信息,请访问此帖子: https://stackoverflow.com/a/49126536/5506730