简体   繁体   English

create-react-app 无法启动脚本后

[英]after create-react-app failed to start script

Failed at the start script and didn't run nothing, while running the following command:在运行以下命令时启动脚本失败并且没有运行任何内容:
npm start

The Error错误


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "webpack-dev-server": "3.2.1"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:

  /home/akhilbatchu/node_modules/webpack-dev-server (version: 3.8.1) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "webpack-dev-server" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /home/akhilbatchu/node_modules/webpack-dev-server is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls webpack-dev-server in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed webpack-dev-server.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appnamsse@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the appnamsse@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!     /home/akhilbatchu/.npm/_logs/2019-11-14T06_22_13_747Z-debug.log

Here is the complete log about what happened:以下是有关所发生事件的完整日志:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/node',
1 verbose cli   '/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/npm',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle appnamsse@0.1.0~prestart: appnamsse@0.1.0
6 info lifecycle appnamsse@0.1.0~start: appnamsse@0.1.0
7 verbose lifecycle appnamsse@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle appnamsse@0.1.0~start: PATH: /home/akhilbatchu/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/akhilbatchu/appnamsse/node_modules/.bin:/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin:/home/akhilbatchu/anaconda3/bin:/home/akhilbatchu/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
9 verbose lifecycle appnamsse@0.1.0~start: CWD: /home/akhilbatchu/appnamsse
10 silly lifecycle appnamsse@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle appnamsse@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle appnamsse@0.1.0~start: Failed to exec start script
13 verbose stack Error: appnamsse@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/home/akhilbatchu/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:210:5)
13 verbose stack     at ChildProcess.<anonymous> (/home/akhilbatchu/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:210:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid appnamsse@0.1.0
15 verbose cwd /home/akhilbatchu/appnamsse
16 verbose Linux 4.15.0-64-generic
17 verbose argv "/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/node" "/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/npm" "start"
18 verbose node v12.13.0
19 verbose npm  v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error appnamsse@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the appnamsse@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Versions :版本
Node: v12.13.0节点:v12.13.0
NPM: v6.12.0 NPM:v6.12.0

Environment环境
react: "^16.11.0",反应:“^16.11.0”,
react-dom: "^16.11.0",反应域:“^16.11.0”,
react-scripts: "3.2.0"反应脚本:“3.2.0”

Could anyone please help me as I am not able to figure out what is going wrong and completely new to react.任何人都可以帮助我,因为我无法弄清楚出了什么问题并且是全新的反应。

Thank you.谢谢你。

Have you installed the dependencies.您是否安装了依赖项。

npm install

If it doesn't work delete the node_modules folder from project.如果它不起作用,请从项目中删除 node_modules 文件夹。 then然后

npm install
npm start 

Did you read the first error message?您是否阅读了第一条错误消息?

It says (step 6) you have (accidentally, probably) installed a copy of webpack-dev-server into your home directory它说(第 6 步)你已经(不小心,可能)将webpack-dev-server的副本安装到你的主目录中

/home/akhilbatchu/node_modules/webpack-dev-server

Get rid of that copy (for instance, rename /home/akhilbatchu/node_modules into /home/akhilbatchu/node_modules_unused if you don't want to outright remove it), then try again.删除该副本(例如,如果您不想完全删除它, /home/akhilbatchu/node_modules重命名为/home/akhilbatchu/node_modules_unused ),然后重试。

I did followed this steps to work我确实按照这个步骤工作

  1. npm install -g npm@latest it'll update npm, in case your modules are not updated npm install -g npm@latest它将更新 npm,以防您的模块未更新

  2. rm -rf node_modules

    Delete node_modules in your project folder.删除项目文件夹中的 node_modules。 as mentioned in the log如日志中所述

  3. npm install

    Run npm install or yarn, depending on the package manager you use.运行 npm install 或 yarn,具体取决于您使用的 package 管理器。 as it is mentioned in the console正如控制台中提到的

暂无
暂无

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

相关问题 使用 npx create-react-app 创建的应用无法启动, - App created with npx create-react-app failed to start, 无法运行 NPM 在 create-react-app 之后启动 - Not able to run NPM Start after create-react-app npm start 脚本在安装 create-react-app my-first-react-app 后立即返回错误 - npm start script returns error immediately after installing create-react-app my-first-react-app 使用 create-react-app 创建新的 react 项目后,npm start 失败 - npm start fails after creating a new react project using create-react-app NPM 脚本“启动”退出,但未指示 create-react-app 服务器正在侦听请求 - The NPM script 'start' exited without indicating that the create-react-app server was listening for requests 如何修复此 npm 开始不起作用(在 npx create-react-app 之后) - how to fix this npm start not working ( after npx create-react-app ) 使用 npx create-react-app 创建应用后<myproject> ,并使用“npm start”启动应用程序我得到了下面提到的这个错误</myproject> - After creating app using npx create-react-app <myproject> , and start app by using "npm start" i got this error mentioned below 仅在 Documents 目录中运行 create-react-app 后,Npm 开始不起作用 - Npm start not working after running create-react-app ONLY in Documents directory 删除旧的 create-react-app 后如何创建 create-react-app - How to create a create-react-app after deleting an old create-react-app 在创建反应项目时在“npx create-react-app my-app”之后运行命令“npm start”时出错 - getting error when run command 'npm start' after 'npx create-react-app my-app' in creating a react project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM