我尝试使用命令
通过Yeoman构建Angular" yo angular"
一切正常,直到我到达tmp目录:
npm ERR! Error: EACCES, mkdir '/home/colin/tmp/npm-10021-myBKjnB0'
npm ERR! { [Error: EACCES, mkdir '/home/colin/tmp/npm-10021-myBKjnB0']
npm ERR! stack: 'Error: EACCES, mkdir \'/home/colin/tmp/npm-10021-myBKjnB0\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/colin/tmp/npm-10021-myBKjnB0' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.8.0-37-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/colin/Desktop/ang-news
npm ERR! node -v v0.11.10-pre
npm ERR! npm -v 1.3.15
npm ERR! path /home/colin/tmp/npm-10021-myBKjnB0
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! stack Error: EACCES, mkdir '/home/colin/tmp/npm-10021-myBKjnB0'
npm http 304 https://registry.npmjs.org/grunt-contrib-jshint
npm http 304 https://registry.npmjs.org/grunt-svgmin
npm http 304 https://registry.npmjs.org/grunt-rev
npm http 304 https://registry.npmjs.org/jshint-stylish
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/colin/Desktop/ang-news/npm-debug.log
npm ERR! not ok code 0
/home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/lib/detect-dependencies.js:55
if (_.isString(componentConfigFile.main)) {
^
TypeError: Cannot read property 'main' of undefined
at findMainFiles (/home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/lib/detect-dependencies.js:55:37)
at /home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/lib/detect-dependencies.js:101:17
at forOwn (/home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/node_modules/lodash/dist/lodash.js:1301:15)
at Function.forEach (/home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/node_modules/lodash/dist/lodash.js:2595:9)
at detect (/home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/lib/detect-dependencies.js:300:5)
at module.exports (/home/colin/npm/lib/node_modules/generator-angular/node_modules/wiredep/wiredep.js:39:39)
at Generator._injectDependencies (/home/colin/npm/lib/node_modules/generator-angular/app/index.js:277:5)
at /home/colin/npm/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:232:13
at /home/colin/npm/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:113:21
at /home/colin/npm/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:24:16
colin@Studio-XPS-1640:~/Desktop/ang-news$ npm http 304 https://registry.npmjs.org/karma-ng-html2js-preprocessor
npm ERR! Error: EACCES, mkdir '/home/colin/tmp/npm-10035-irWQWzi0'
npm ERR! { [Error: EACCES, mkdir '/home/colin/tmp/npm-10035-irWQWzi0']
npm ERR! stack: 'Error: EACCES, mkdir \'/home/colin/tmp/npm-10035-irWQWzi0\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/colin/tmp/npm-10035-irWQWzi0' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.8.0-37-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "grunt-karma" "karma-ng-html2js-preprocessor" "karma-ng-scenario" "--save-dev"
npm ERR! cwd /home/colin/Desktop/ang-news
npm ERR! node -v v0.11.10-pre
npm ERR! npm -v 1.3.15
npm ERR! path /home/colin/tmp/npm-10035-irWQWzi0
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! stack Error: EACCES, mkdir '/home/colin/tmp/npm-10035-irWQWzi0'
npm http 304 https://registry.npmjs.org/grunt-karma
npm http 304 https://registry.npmjs.org/karma-ng-scenario
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/colin/Desktop/ang-news/npm-debug.log
npm ERR! not ok code 0
我假设这是一个有权限的错误,但你不能用sudo运行yo命令,因为它是一个单独的用户。
我使用chown更改了/ usr / local的权限,但我不确定这是否会影响我的问题。
答案 0 :(得分:1)
我/ home / colin / tmp的权限有误。之所以发生这种情况,是因为我过去曾经做过sudo npm install,并且npm不能很好地处理这个问题。
sudo chown colin /home/colin/tmp -R
以上内容更改了tmp文件夹的用户colin的所有权限。