我已经创建了一个 React 应用程序,但我正在努力解决由 npm start
引起的问题。每当我在 Windows 7 32 位操作系统上使用命令 react-scripts start
时都会弹出错误。
(注意:我使用 npx create-react-app my-react 来创建应用程序)
这里是错误:
> my-react@0.1.0 start D:\WEB DEVELOPMENT\MyReact\my-react
> react-scripts start
internal/modules/cjs/loader.js:628
throw e;
^
Error: No valid exports main found for 'D:\WEB DEVELOPMENT\MyReact\my-react\node_modules\postcss-safe-parser\node_modules\postcss'
←[90m at resolveExportsTarget (internal/modules/cjs/loader.js:625:9)←[39m
←[90m at applyExports (internal/modules/cjs/loader.js:502:14)←[39m
←[90m at resolveExports (internal/modules/cjs/loader.js:551:12)←[39m
←[90m at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)←[39m
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:855:27)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:1033:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:72:18)←[39m
at Object.<anonymous> (D:\WEB DEVELOPMENT\MyReact\my-react\node_modules\←[4mpostcss-safe-parser←[24m\lib\safe-parse.js:1:17)
←[90m at Module._compile (internal/modules/cjs/loader.js:1144:30)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-react@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-react@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! D:\ALL~FILE\APPS\Roaming\npm-cache\_logs\2021-03-20T16_33_30_649Z-debug.log ```
答案 0 :(得分:1)
你可以试试这个:
node_modules
个文件夹package-lock.json
文件npm install
然后 npm start
说明:看起来有些软件包安装不正确。这些说明将卸载您的 React 应用程序正常运行所需的各种包,然后重新安装。