`yo angular` gives error: npm ERR! code ENOENT npm ERR! errno 34 (yes I have cleaned the cache and set .npmignore)

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

I tried to run yo angular in a new project directory, but it gave me the ENOENT error somewhere along the way. Yes I have looked at this similar question, but its solution doesn't work for me.

I ran these things on the empty new project directory right before running yo angular:

touch .npmignore npm cache clear npm cache clean 

But I still get:

npm ERR! Error: ENOENT, lstat '/home/ubuntu/app_c/node_modules/grunt/    internal-tasks/bump.js' npm ERR! If you need help, you may report this *entire* log,  npm ERR! including the npm and node versions, at: npm ERR!       npm ERR! System Linux 3.2.0-54-virtual npm ERR! command "/home/ubuntu/local/bin/node" "/home/ubuntu/local/bin/  npm" "install" npm ERR! cwd /home/ubuntu/app_c npm ERR! node -v v0.10.26 npm ERR! npm -v 1.4.3 npm ERR! path /home/ubuntu/app_c/node_modules/grunt/internal-tasks/bump. js npm ERR! fstream_path /home/ubuntu/app_c/node_modules/grunt/internal-    tasks/bump.js npm ERR! fstream_type File  npm ERR! fstream_class FileWriter npm ERR! code ENOENT npm ERR! errno 34 npm ERR! fstream_stack /home/ubuntu/local/lib/node_modules/npm/          node_modules/fstream/lib/writer.js:284:26 npm ERR! fstream_stack Object.oncomplete (fs.js:107:15) 

How can I fix it?


Here is the history of ALL the commands, in chronological order, that I ran on a brand new Ubuntu Server 12.04.3, so you can see exactly what led up to this point, and where I have installed various packages.

This question is linked to an npm github issue.

回答1:

EDIT: npm update -g followed by npm cache clear should work for most. However, when first installing on Mac OS you may need to navigate to your usr/local/lib/node_modules folder once nodeJS is first installed and grant read/write permission to "Everyone". Node won't be able to installed additional workflow components globally until those permissions are released. You don't want to sudo the npm install commands, because then those tools won't have sudo access to run after the fact. Read/write permissions are changed by right-clicking the folder and going to "Get info" then changing permissions at bottom of popup.

I had this same issue on Windows 7 machine. Here are the steps I took to resolve:

  • repair Node installation
  • open elevated cli
  • run npm update -g
  • run npm cache clear
  • run npm install -g yo
  • run npm cache clear
  • run npm install -g generator-angular
  • run npm cache clear
  • created new directory
  • run yo angular test
  • run npm cache clear
  • run grunt serve

I did run into some other issues with karma.conf.js where the paths had a \ instead of / for bower_components. Also, I noticed the optional angular modules were injected in my app.js despite not including them all in my yo build from the cli. I have reported these issues on github.



回答2:

npm ERR! command "/home/ubuntu/local/bin/node"

Are you installing in a user directory? I did and had ENOENT errors too.

I had to mkdir some directories. If they're not there, try creating some of the directories in the debug.log, like lib/node_modules.



回答3:

Update node (and npm) to the latest version, and this should solve the issue.



回答4:

These ENOENT (and sometimes EACCES) errors are often caused by old versions of npm. Unfortunately even the latest version of node does not distribute the current version of npm.

After installing node, run npm -v. If you don't see 2.1.18 or later, you should upgrade following the official instructions here https://github.com/npm/npm/wiki/Troubleshooting#try-the-latest-stable-version-of-npm

On OSX the quick way to upgrade is sudo npm install -g npm@latest

On Windows, follow the guide in the wiki or read this answer How do I update npm on Windows?

cmd.exe cd C:\Program Files (x86)\nodejs npm install npm@latest



回答5:

My problem was a broken package.json. Maybe this will help someone.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!