【问题标题】:Error: Cannot find module './util/resolveCommand'错误:找不到模块“./util/resolveCommand”
【发布时间】:2018-05-17 06:27:49
【问题描述】:

由于我认为 util npm 存在问题,我无法再启动 npm。 我尝试更新所有软件包并删除 util 并重新安装它。我该如何解决这个问题?


Error: Cannot find module './util/resolveCommand'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/cyruslognonne/Dropbox/C-T-L-K_Master/A_Mandats/A_En cours/LEV/B_Jam/lev_dev/node_modules/cross-spawn/lib/parse.js:3:22)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lev_dev@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the lev_dev@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cyruslognonne/.npm/_logs/2017-12-03T19_21_25_874Z-debug.log

这是我的 package.json。

{
  "name": "lev_dev",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "package.json": "^2.0.1",
    "react": "^16.1.1",
    "react-dom": "^16.1.1",
    "react-marquee": "^0.1.1",
    "react-scripts": "1.0.17",
    "react-slick": "^0.15.4",
    "slick-carousel": "^1.8.1",
    "util": "^0.10.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

谢谢,赛勒斯

【问题讨论】:

  • 有时即使您导入了工具包中的包,您也会收到此错误。我得到了这个记录器包。 const logger = require('./utils/logger');

标签: node.js npm npm-install npm-start


【解决方案1】:

如错误所述,问题出在cross-spawn 模块上,该模块由react-scripts 使用。问题不是因为util 模块。

尝试以下方法正确更新依赖关系,看看是否有效。

npm install -g npm@latest # to update npm.
rm -rf node_modules # to remove the existing modules.
npm install # to re-install the project dependencies.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-15
    • 1970-01-01
    • 2021-12-13
    • 2017-11-07
    • 2019-04-17
    • 2022-11-10
    • 2023-04-11
    相关资源
    最近更新 更多