npm 错误!错误:生成 ENOENT

Posted

技术标签:

【中文标题】npm 错误!错误:生成 ENOENT【英文标题】:npm ERR! Error: spawn ENOENT 【发布时间】:2015-03-12 14:06:50 【问题描述】:

当我尝试将我的代码推送到 heroku 时,出现以下错误。之前一切正常。突然出事了。

-----> Node.js app detected

       Node engine:         0.10.x
       Npm engine:          1.1.x
       Start mechanism:     Procfile
       node_modules source: prebuilt
       node_modules cached: true

       NPM_CONFIG_PRODUCTION=true
       NODE_MODULES_CACHE=true

-----> Installing binaries
       Resolving node version 0.10.x via semver.io...
       Downloading and installing node 0.10.35...
       Resolving npm version 1.1.x via semver.io...
       Downloading and installing npm 1.1.71 (replacing version 1.4.28)...

-----> Building dependencies
       Rebuilding any native modules for this architecture
       npm WARN package.json OutboxProApi@0.0.1 No README.md file found!
       npm ERR! Error: spawn ENOENT
       npm ERR!     at errnoException (child_process.js:1011:11)
       npm ERR!     at Process.ChildProcess._handle.onexit (child_process.js:802:34)
       npm ERR! If you need help, you may report this log at:
       npm ERR!     <http://github.com/isaacs/npm/issues>
       npm ERR! or email it to:
       npm ERR!     <npm-@googlegroups.com>

       npm ERR! System Linux 3.8.11-ec2
       npm ERR! command "node" "/tmp/build_fc3e8717fd7f68f9f6a9e93833388643/.heroku/node/bin/npm" "rebuild"
       npm ERR! cwd /tmp/build_fc3e8717fd7f68f9f6a9e93833388643
       npm ERR! node -v v0.10.35
       npm ERR! npm -v 1.1.71
       npm ERR! syscall spawn
       npm ERR! code ENOENT
       npm ERR! errno ENOENT
       npm ERR! 
       npm ERR! Additional logging details can be found in:
       npm ERR!     /tmp/build_fc3e8717fd7f68f9f6a9e93833388643/npm-debug.log
       npm ERR! not ok code 0

-----> Build failed

       WARNING: Avoid checking node_modules into source control
       https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-

       WARNING: This version of npm (1.1.71) has several known issues - consider upgrading to the latest release (2.1.18)
       https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version

       We're sorry this build is failing! If you can't find the issue in application code,
       please submit a ticket so we can help: https://help.heroku.com/
       You can also try reverting to our legacy Node.js buildpack:
       heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#v63

       Love,
       Heroku

我有以下 packejer.json 文件


  "name": "testApp",
  "description": "TestApp",
  "version": "0.0.1",
  "private": true,
  "main": "app.js",
  "dependencies": 
    "aws-sdk": "~2.0.0-rc9",
    "bitly": "~1.2.5",
    "connect-redis": "~1.4.6",
    "cookie-signature": "~1.0.3",
    "crypto": "0.0.3",
    "elasticsearch": "~1.5.5",
    "embedly": "~1.0.2",
    "express": ">= 3.4.7",
    "forky": ">= 0.0.2",
    "http": "0.0.0",
    "image-size": "^0.3.3",
    "mmm": "~0.2.2",
    "moment": "~2.5.1",
    "moment-timezone": "0.0.3",
    "nimble": "0.0.2",
    "node-uuid": "^1.4.1",
    "nodetime": "^0.8.15",
    "redis": "^0.12.1",
    "request": "~2.33.0",
    "sanitizer": "~0.1.1",
    "url": "~0.7.9",
    "validator": "~3.2.1"
  ,
  "engines": 
    "node": "0.10.x",
    "npm": "1.1.x"
  ,
  "scripts": 
    "test": "node_modules/.bin/mocha tests -R spec"
  ,
  "devDependencies": 
    "assert": "^1.1.2",
    "chai": "^1.10.0",
    "mocha": ">= 1.17.1",
    "precommit-hook": "",
    "should": "^4.3.0",
    "sinon": "^1.12.1",
    "sinon-chai": "^2.6.0",
    "supertest": "^0.15.0"
  

请帮我解决这个问题。谢谢你。

【问题讨论】:

您使用的是最新版本的 Node,但 npm 1.1.x 已经有几年历史了。也许尝试更新它。 @Steve 谢谢史蒂夫。让我知道如何在不更新其他模块的情况下将 npm 1.1.x 更新到更高版本。 【参考方案1】:

您可以在 package.json 中更新 npm 版本,因为您提供的 npm 版本已过时。

"engines": 
   .... /*other settings*/
    "npm": "2.1.x" /* latest version*/
 

会解决问题的。

【讨论】:

【参考方案2】:

您的机器上必须安装 msysgit。另外,我的 Git 安装路径是“C:\Program Files (x86)\Git”。你的可能不一样。请在继续之前检查您的位置。

msysgit(gitforwindows.org) 去这个网站可以下载Git

【讨论】:

嗨 Kajal,欢迎来到 Stack Overflow。如果您想添加信息或澄清某些内容,您可以编辑您的答案而不是对其发表评论【参考方案3】:

我已经通过将 npm 更新到稳定版本来解决这个问题。

"engines": 
    "node": "0.10.x",
    "npm": "2.1.x"
  

https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version

【讨论】:

遇到了同样的问题。如上所述将节点更新到 0.10 对我有用。

以上是关于npm 错误!错误:生成 ENOENT的主要内容,如果未能解决你的问题,请参考以下文章

npm 错误!错误:生成 ENOENT

错误:生成 npm ENOENT

docker-compose 无法以 npm ERR 启动! enoent ENOENT:没有这样的文件或目录,打开'/usr/src/app/package.json'

npm install 生成大量错误

npm ERR! code ENOENT npm ERR! syscall open npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file

Cloud Functions 在 Windows 上的 lint 期间部署错误:“enoent ENOENT:没有这样的文件或目录”