0

我正在构建一个 React 应用程序。我通过 npm 手动安装了 yargs 和 argsert。出于某种原因,当我启动开发服务器时,出现以下错误和堆栈跟踪。有问题的两个模块被明确列为 argsert 和 yargs。我不确定如何进行。任何反馈将不胜感激。

webpack-dev-server --mode 开发

module.js:549
throw err;
^

Error: Cannot find module './lib/argsert'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/josh/devel/react-app/frontend/node_modules/webpack-dev-server/node_modules/yargs/yargs.js:2:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

包.json

 {                                                                                                                                                                       
   "name": "react-app",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
   "start": "webpack-dev-server --mode development",
   "build": "webpack --mode production",
   "test": "echo \"Error: no test specified\" && exit 1"
  },
   "keywords": [],
   "author": "",
   "license": "ISC",
   "devDependencies": {
   "@babel/core": "^7.8.7",
   "@babel/preset-env": "^7.8.7",
   "@babel/preset-react": "^7.8.3",
   "babel-loader": "^8.0.6",
   "html-loader": "^0.5.5",
   "html-webpack-plugin": "^3.2.0",
   "webpack": "^4.42.0",
   "webpack-cli": "^3.3.11",
   "webpack-dev-server": "^3.10.3"
   },
   "dependencies": {
   "argsert": "^1.0.9",
   "babel-loader": "^8.0.6",
   "react": "^16.13.0",
   "react-dom": "^16.13.0",
   "react-router-dom": "^5.1.2",
   "weak-key": "^1.0.1",
   "yargs": "^15.3.1"
  }
}
4

2 回答 2

0

如果它不起作用,请使用npm i argsert yargs尝试,npm install即使它不工作也很困难。从中删除 argsert 和 yargspackage.json并重新安装。

于 2020-03-18T06:44:23.660 回答
0

我已经从源代码安装了 node 和 npm,这似乎已经解决了这个问题。感谢大家的帮助。

于 2020-03-18T10:14:48.517 回答