npm安装时发生错误 [英] error when npm install
问题描述
我是一个初学者,我想学习Angular,所以我想安装一个带有angular-seed的新项目.但是当我执行npm install时,出现错误,我不知道从哪里来.我已经安装了节点.版本是5.5.0.这是我在控制台中遇到的错误.
I'm a beginner and I'm trying to learn Angular so I'm trying to install a new project with angular-seed. But when I do npm install I get an error that I dont know where is coming from. I have node installed. The version is 5.5.0. Ad this is the error I get in console.
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
推荐答案
问题:您(用户)没有对该目录的正确权限集.
ISSUE: You (the user) don't have the right set of permissions for the directory.
当前的解决方法是使用sudo运行npm安装,但这可能会给您同样的错误,或者安装不正确.
The instant way out is to run the npm install using sudo, but this may give you the same error, or improper installation.
Solution/Suggestion: Change npm's Default Directory (from official docs)
备份计算机,然后继续前进.
Back-up your computer before moving forward.
(可选)如果安装错误,请先将其卸载:
(optional) In case you have a erroneous installation, first uninstall it:
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
-
为全局安装创建目录:
Make a directory for global installations:
mkdir〜/.npm-global
mkdir ~/.npm-global
配置npm以使用新的目录路径:
Configure npm to use the new directory path:
npm配置设置前缀'〜/.npm-global'
npm config set prefix '~/.npm-global'
打开或创建一个〜/.profile
或〜/.bash_profile
文件并添加以下行:
Open or create a ~/.profile
or ~/.bash_profile
file and add this line:
导出PATH =〜/.npm-global/bin:$ PATH
export PATH=~/.npm-global/bin:$PATH
返回命令行,更新系统变量,或重新启动终端:
Back on the command line, update your system variables, or restart the terminal:
源〜/.profile
source ~/.profile
(可选)测试:不使用sudo全局下载软件包.
(optional) Test: Download a package globally without using sudo.
npm install -g jshint
npm install -g jshint
这篇关于npm安装时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!