简体   繁体   English

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

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

I tried to run yo angular in a new project directory, but it gave me the ENOENT error somewhere along the way.我试图在一个新的项目目录中运行yo angular ,但它在途中的某个地方给了我 ENOENT 错误。 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 :在运行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!     <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)

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.这是我在全新的 Ubuntu 服务器 12.04.3 上运行的所有命令的历史记录,按时间顺序排列,因此您可以确切地看到导致这一点的原因,以及我在哪里安装了各种软件包。

This question is linked to an npm github issue .此问题与 npm github 问题相关联。

EDIT: npm update -g followed by npm cache clear should work for most. 编辑: npm update -g后跟npm cache clear应该适用于大多数。 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". 但是,首次在Mac OS上安装时,可能需要在首次安装usr/local/lib/node_modules导航到usr/local/lib/node_modules文件夹,并向“Everyone”授予读/写权限。 Node won't be able to installed additional workflow components globally until those permissions are released. 在释放这些权限之前,Node将无法全局安装其他工作流组件。 You don't want to sudo the npm install commands, because then those tools won't have sudo access to run after the fact. 你不想sudo npm install命令,因为那些工具在事后不会有sudo访问权限。 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. 我在Windows 7机器上遇到了同样的问题。 Here are the steps I took to resolve: 以下是我要解决的步骤:

  • repair Node installation 修复节点安装
  • open elevated cli 打开升高的cli
  • run npm update -g 运行npm update -g
  • run npm cache clear 运行npm cache clear
  • run npm install -g yo 运行npm install -g yo
  • run npm cache clear 运行npm cache clear
  • run npm install -g generator-angular 运行npm install -g generator-angular
  • run npm cache clear 运行npm cache clear
  • created new directory 创建了新目录
  • run yo angular test yo angular test
  • run npm cache clear 运行npm cache clear
  • run grunt serve 运行grunt serve

I did run into some other issues with karma.conf.js where the paths had a \\ instead of / for bower_components. 我确实遇到了karma.conf.js的一些其他问题,其中路径有一个\\而不是/为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. 另外,我注意到可选的角度模块是在我的app.js中注入的,尽管不是将它们全部包含在我的cli构建中。 I have reported these issues on github. 我在github上报告了这些问题。

npm ERR! 错误的ERR! command "/home/ubuntu/local/bin/node" 命令“/ home / ubuntu / local / bin / node”

Are you installing in a user directory? 您是否在用户目录中安装? I did and had ENOENT errors too. 我做了,也有ENOENT错误。

I had to mkdir some directories. 我不得不mkdir一些目录。 If they're not there, try creating some of the directories in the debug.log, like lib/node_modules. 如果它们不存在,请尝试在debug.log中创建一些目录,如lib / node_modules。

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

These ENOENT (and sometimes EACCES ) errors are often caused by old versions of npm . 这些ENOENT (有时是EACCES )错误通常是由旧版本的npm引起的。 Unfortunately even the latest version of node does not distribute the current version of npm . 不幸的是,即使是最新版本的node也不会分发当前版本的npm

After installing node , run npm -v . 安装node ,运行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 如果您没有看到2.1.18或更高版本,则应按照此处的官方说明进行升级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 在OSX上,升级的快速方法是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? 在Windows上,请按照Wiki中的指南或阅读此答案如何在Windows上更新npm?

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

My problem was a broken package.json . 我的问题是破解了package.json Maybe this will help someone. 也许这会对某人有所帮助。

This problem can really be caused by several things and it is strange that npm is not able to give the exact cause of the problem.这个问题确实可能是由几件事引起的,奇怪的是 npm 无法给出问题的确切原因。

In my case, this problem was caused by importing a scss file.就我而言,此问题是由导入 scss 文件引起的。 The specified path was not correct.指定的路径不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM