`yo angular`给出错误:npm ERR!代码ENOENT npm ERR!errno 34(是的,我已清理缓存并设置.npmignore)

ran*_*a1k 21 node.js npm angularjs yeoman yeoman-generator

我试图yo angular在一个新的项目目录中运行,但它给了我一路上的ENOENT错误.是的我看过这个类似的问题,但它的解决方案对我不起作用.

我在运行前在空的新项目目录上运行了这些东西yo angular:

touch .npmignore
npm cache clear
npm cache clean
Run Code Online (Sandbox Code Playgroud)

但我仍然得到:

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!     <http://github.com/npm/npm/issues>

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)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?


这是所有命令历史记录,按时间顺序排列,我在一个全新的Ubuntu Server 12.04.3上运行,因此您可以看到到底是什么导致了这一点,以及我在哪里安装了各种软件包.

这个问题与npm github问题有关.

Jam*_*mar 27

编辑:npm update -g其次npm cache clear应该适用于大多数人.但是,首次在Mac OS上安装时,您可能需要在usr/local/lib/node_modules首次安装nodeJS后导航到您的文件夹,并向"Everyone"授予读/写权限.在释放这些权限之前,Node将无法全局安装其他工作流组件.你不想sudo npm install命令,因为那些工具在事后不会有sudo访问权限.通过右键单击文件夹并转到"获取信息"然后更改弹出窗口底部的权限来更改读/写权限.

我在Windows 7机器上遇到了同样的问题.以下是我要解决的步骤:

  • 修复节点安装
  • 打开升高的cli
  • npm update -g
  • npm cache clear
  • npm install -g yo
  • npm cache clear
  • npm install -g generator-angular
  • npm cache clear
  • 创建了新目录
  • yo angular test
  • npm cache clear
  • grunt serve

我确实遇到了karma.conf.js的一些其他问题,其中路径有一个\而不是/bower_components.另外,我注意到可选的角度模块是在我的app.js中注入的,尽管不是将它们全部包含在我的cli构建中.我在github上报告了这些问题.

  • 这为我修好了.我认为关键的一步是`npm update -g`,然后是`npm cache clear`. (6认同)

Nik*_* M. 1

将节点(和 npm)更新到最新版本,这应该可以解决问题。