Lots of “npm ERR!”s when running `yo angular`

2019-02-26 06:13发布

I'm trying to get Yeoman to work but it's been one wall after another. Thank God for stackoverflow and all you nice people helping out. Anyways ...

I've been trying to run yo angular. But I'm getting a bunch of npm ERR! including:

npm ERR! Please try running this command again as root/Administrator.

Since I can't use sudo on yo, I followed the mostly accepted advice and changed some configuration hoping to fix this problem. Here are the commands I ran, which were based on the recommendation.

But I'm still getting the same error!

Here is my yo angular's npm-debug.log

Here is my yo angular's stderr.log

Here is my yo angular's stdout.log

How should I fix these errors?

Thank you so much in advance.


Update:

After alex's suggestion of doing sudo chown ubuntu /home/ubuntu/tmp -Rv, the run as root error did go away, however I still have these errors after running yo angular in a new directory. I'm displaying the errors with cat -n stderr.log | grep -ir err (it's strange that npm-debug.log wasn't generated this time):

   218  npm ERR! Error: ENOENT, lstat '/home/ubuntu/youtube_5/node_modules/grunt/lib/grunt/task.js'
   219  npm ERR! If you need help, you may report this *entire* log,
   220  npm ERR! including the npm and node versions, at:
   221  npm ERR!     <http://github.com/npm/npm/issues>
   223  npm ERR! System Linux 3.2.0-54-virtual
   224  npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-karma" "karma-ng-html2js-preprocessor" "karma-ng-scenario" "--save-dev"
   225  npm ERR! cwd /home/ubuntu/youtube_5
   226  npm ERR! node -v v0.10.25
   227  npm ERR! npm -v 1.4.2
   228  npm ERR! path /home/ubuntu/youtube_5/node_modules/grunt/lib/grunt/task.js
   229  npm ERR! fstream_path /home/ubuntu/youtube_5/node_modules/grunt/lib/grunt/task.js
   230  npm ERR! fstream_type File
   231  npm ERR! fstream_class FileWriter
   232  npm ERR! code ENOENT
   233  npm ERR! errno 34
   234  npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
   235  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  1102  npm ERR! 
  1103  npm ERR! Additional logging details can be found in:
  1104  npm ERR!     /home/ubuntu/youtube_5/npm-debug.log
  1105  npm ERR! not ok code 0

Update2: After some research, I solved this new ENOENT problem with sudo npm cache clear.

Thanks StackOverflow.

2条回答
Anthone
2楼-- · 2019-02-26 06:43

80 error Error: EACCES, mkdir '/home/ubuntu/tmp/npm-26883-sBYbfAy6'

Okay, so your /home/ubuntu/tmp has wrong permissions. It happened because you did sudo npm install in the past, and npm doesn't handle this well enough.

Run sudo chown ubuntu /home/ubuntu/tmp -Rv to fix this issue, or just delete that folder.

查看更多
时光不老,我们不散
3楼-- · 2019-02-26 06:47

I was getting all kinds of crazy errors even after applying the fixes above, finally I ran "chmod -R 777 /home/[moi]/.npm, and it now runs without any errors.

查看更多
登录 后发表回答