原来运行得好好的react我的项目,忽然运行不胜利了,提醒如下谬误

$ npm start> react-app-rewired startinternal/modules/cjs/loader.js:589    throw err;    ^Error: Cannot find module 'D:\my_project\node_modules\react-scripts/config/webpack.config.dev.js'    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)    at Function.Module._load (internal/modules/cjs/loader.js:513:25)    at Module.require (internal/modules/cjs/loader.js:643:17)    at require (internal/modules/cjs/helpers.js:22:18)    at Object.<anonymous> (D:\my_project\node_modules\react-app-rewired\scripts\start.js:18:23)    at Module._compile (internal/modules/cjs/loader.js:707:30)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)    at Module.load (internal/modules/cjs/loader.js:605:32)    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)    at Function.Module._load (internal/modules/cjs/loader.js:536:3)npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! my_project@0.1.0 start: `react-app-rewired start --scripts-version react-scripts-ts`npm ERR! Exit status 1npm ERR!npm ERR! Failed at the my_project@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!     C:\Users\...\AppData\Roaming\npm-cache\_logs\2019-01-19T10_56_58_751Z-debug.log

通过四处寻找,在github找到了起因解释,只不过他的解释是针对应用了ts下的react我的项目,然而原理雷同内容如下

This has been caused by recent changes to CRA (2.1.2) where they merged the webpack.config.dev.js and webpack.config.prod.js into a single file webpack.config.js. See #343 and #345 for more details on the change.

The adjustment to paths made in react-app-rewired in order to continue to be able to be used with CRA looks for a react-scripts version number greater than or equal to 2.1.2. The react-scripts-ts version number has been higher than that for the last ~18 months, so react-app-rewired is treating it according to the merged webpack config instead of the split one.

To solve it, you'll need to install an older version of react-app-rewired that doesn't have this change. I believe the last version of react-app-rewired that will be compatible with react-scripts-ts is version 1.6.2. The versions for 2.x have the breaking change to support CRA 2.1.2 and beyond that is misfiring on react-scripts-ts.

Use yarn add react-app-rewired@1.6.2 or npm install react-app-rewired@1.6.2 to step back to the last of the 1.x versions of react-app-rewired - it will install the older version and lock the version number to exactly that version so that it doesn't get upgraded to a newer version accidentally in future.

大抵意思就是react-app-rewired这个插件降级导致了不会独自生成dev和prod配置文件了,所以导致文件找不到。须要将react-app-rewired版本固定在1.6.2,这样解决能解决下面的问题,

然而又呈现了一个新问题,大抵内容是can not find module react_script/package.json

剖析应该也是版本问题导致的,所以通过git版本回退找到了以前的代码的package.json中react_script的应用版本是2.0.3,所以将版本也固定在了2.0.3

删掉node_modules目录,从新执行npm install

npm start 启动我的项目,胜利启动并关上浏览器tab页。