React:'Cannot find module 'react-scripts/package.json' 报错解决方案

在配置create-react-app的时候,使用了customize-cra插件,将启动代码改成了

"start": "react-app-rewired start"

运行npm start后报错,如下:

internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module 'react-scripts/package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.resolve (internal/modules/cjs/helpers.js:30:19)
    at Object. (D:\study\react-study\react_01\node_modules\react-app-rewired\scripts\utils\paths.js:27:11)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-app-rewired start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\Administrator\AppData\Roaming\npm-cache\_logs\2019-07-31T06_44_37_975Z-debug.log

错误中提示不能找到module 'react-scripts/package.json',所以安装下就可以了
解决方法:

npm install react-scripts -S

End

你可能感兴趣的:(React:'Cannot find module 'react-scripts/package.json' 报错解决方案)