gpt4 book ai didi

node.js - npm start 不起作用。我已经尝试了一切。我很困惑

转载 作者:太空宇宙 更新时间:2023-11-04 02:55:05 26 4
gpt4 key购买 nike

因此,每当我在 React 项目中运行 npm start 时,都会出现以下错误:

myapp@0.1.0 start C:\Users\AyaLe\Desktop\React\myapp react-scripts start

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": "4.19.1"

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

C:\Users\AyaLe\node_modules\webpack (version: 3.10.0)

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

If 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" 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:

  1. 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.

  2. Check if C:\Users\AyaLe\node_modules\webpack is outside your project directory. For example, you might have accidentally installed something in your home folder.

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

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! myapp@0.1.0 start: react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the myapp@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\AyaLe\AppData\Roaming\npm-cache_logs\2018-12-02T10_15_24_630Z-debug.log

此外,每当我尝试安装 webpack-cli 时,它都会要求我安装,它会给我另一个错误

最佳答案

看起来您已经全局安装了 "webpack": "3.10.0",但您需要安装 "webpack": "4.19.1"。这导致了冲突。

您需要执行以下操作:

1. $npm uninstall -g webpack
2. $npm install -g webpack@4.19.1

这应该可以解决问题。

或者,您可以尝试删除 node_modules 文件夹,或者具体删除 node_modules 中的 webpack 文件夹,位置为:

C:\Users\AyaLe\node_modules\webpack (version: 3.10.0)

关于node.js - npm start 不起作用。我已经尝试了一切。我很困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53579310/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com