简体   繁体   English

创建反应应用程序时出现 npm 启动错误

[英]Getting npm start error while creating a react app

I've created a react app, but I am struggling with a problem which it is caused in npm start .我创建了一个反应应用程序,但我正在努力解决它在npm start中引起的问题。 The error pops up whenever I use the command react-scripts start on my windows 7 32 bit OS.每当我在 windows 7 32 位操作系统上使用命令react-scripts start时都会弹出错误。

(NOTE: I used npx create-react-app my-react to creatr the app) (注意:我使用npx create-react-app my-react来创建应用程序)

Here is the error:这是错误:


> 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 ```

You can try this:你可以试试这个:

  1. Delete node_modules folder删除node_modules文件夹
  2. Delete the package-lock.json file which is at the root of your repository删除存储库根目录下的package-lock.json文件
  3. Run these commands: npm install and then npm start运行这些命令: npm install然后npm start

Explanation: It looks like some packages were installed incorrectly.说明: 看起来有些软件包安装不正确。 These instructions will uninstall the various packages your react app needs to run propertly, and install them again.这些说明将卸载您的 react 应用程序需要正确运行的各种包,然后重新安装它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM