gpt4 book ai didi

node.js - 'npm start' 返回错误 : "There might be a problem with the project dependency tree"

转载 作者:行者123 更新时间:2023-11-30 07:49:15 29 4
gpt4 key购买 nike

我是编码新手,对为什么我无法再正确设置 React 有疑问。上周我为此苦苦挣扎,然后终于成功了。但现在我又遇到了同样的问题,但没有任何效果。

我有一个项目,我从 npx create-react-app 开始,然后当我 cd 进入项目时,我遇到了这个问题:

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

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

"webpack": "4.29.6"

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

/Users/aliceparker/node_modules/webpack (version: 4.33.0)

Manually installing incompatible versions is known to causehard-to-debug issues.

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

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

  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 hasnot 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 /Users/aliceparker/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 filein your project. That would permanently disable this preflight checkin 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!

我已按照上述步骤操作。仍然得到这个问题。我还全局卸载了 webpack 并重新安装了它。

这是我的 package.json 文件的样子:

`{
"name": "ravenous-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}`

谁能指导我解决这个问题?
(PS。我试着只创建一个新项目,但遇到了同样的问题......)

最佳答案

在我的例子中,我用这种方式解决了我的问题

  1. 在文件夹 react folder 的根目录下创建一个 .env
  2. .env 文件中输入 SKIP_PREFLIGHT_CHECK=true
  3. 现在在 cmd npm start 中运行。

关于node.js - 'npm start' 返回错误 : "There might be a problem with the project dependency tree",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56528222/

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