【问题标题】:npm ERR! code ENOENT, npm ERR! errno 34npm 错误!代码 ENOENT,npm 错误!错误号 34
【发布时间】:2017-05-24 09:04:50
【问题描述】:

这是我的 React 应用程序的启动脚本。

"scripts": {
    "prestart": "babel-node tools/startMessage.js",
    "start": "npm-run-all --parallel test:watch open:src lint:watch",
    "open:src": "babel-node tools/srcServer.js",
    "lint": "node_modules/.bin/esw webpack.config.* src tools",
    "lint:watch": "npm run lint -- --watch",
    "test": "mocha --reporter progress tools/testSetup.js \"src/**/*.test.js\"",
    "test:watch": "npm run test -- --watch",
    "clean-dist": "npm run remove-dist && mkdir dist",
    "remove-dist": "node_modules/.bin/rimraf ./dist",
    "build:html": "babel-node tools/buildHtml.js",
    "prebuild": "npm-run-all clean-dist test lint build:html",
    "build": "babel-node tools/build.js",
    "postbuild": "babel-node tools/distServer.js"
  },

当我运行 npm start 时,我得到一长串错误。

npm ERR! System Linux 3.10.0-327.36.3.el7.20161025.20.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "run" "lint" "--" "--watch"
npm ERR! cwd /home/user/workspace/shareback-viewer
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! path /home/user/workspace/shareback-viewer/node_modules/lint/package.json
npm ERR! code ENOENT
npm ERR! errno 34......

很明显,npm 脚本失败了,因为它试图寻找错误的路径。 npm 错误!路径 /home/user/workspace/shareback-viewer/node_modules/lint/package.json

我该如何解决这个问题?

【问题讨论】:

  • 顺便说一句……帮自己一个忙,升级到当前版本的 nodejs nodejs.org/en v7.4.0 你正在使用 v0.10.30
  • 啊哎呀,我想这可能是问题所在。解析不正确。

标签: node.js npm


【解决方案1】:

每当我遇到此错误时,删除 node_modules 并再次运行 npm install 似乎可以解决问题,npm start 之后就会开始小变通。我在 GitHub 上似乎有很多关于此的问题,大多数人建议使用上述建议的方法。如果您看到其他 npm 错误,您可以查看 official docs for error troubleshooting。如果仍然出现,请尝试 npm cache clean 命令,注意有时您可能需要添加 --force 标志。希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2014-11-24
    • 1970-01-01
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-12
    • 2020-02-12
    • 2022-10-08
    相关资源
    最近更新 更多