react配置完裝飾器之后運行yarn start時報錯


 配置完裝飾器之后以運行yarn 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 locall
y.

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

"webpack": "4.41.0"

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:

D:\react項目\darengou\node_modules\webpack (version: 4.40.2)

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 .e
nv 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 proje
ct folder.
2. Delete node_modules in your project folder.
3. Remove "webpack" from dependencies and/or devDependencies in the package.js
on 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 st
eps with it instead.
This may help because npm has known issues with package hoisting which may
get resolved in future versions.

6. Check if D:\react項目\xxx名稱\node_modules\webpack is outside your project
directory.
For example, you might have accidentally installed something in your home f
older.

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

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your pro
ject.
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 yo
u find them helpful!

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this comm
and.

 

解決方法:

創建一個名為 .env 的文件 ,在文件里添加SKIP_PREFLIGHT_CHECK=true 這句代碼,保存再yarn start運行就好了。

雖然不知道為什么但是親測有效!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM