react配置完装饰器之后运行yarn start时报错
Posted minus1994
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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运行就好了。
虽然不知道为什么但是亲测有效!!!
以上是关于react配置完装饰器之后运行yarn start时报错的主要内容,如果未能解决你的问题,请参考以下文章
react项目的中使用mobx状态管理安装ES7装饰器(Decorator)语法教程