[英]'prop-types' should be listed in the project's dependencies, not devDependencies
I ran npm install prop-types --save-dev
and started getting this error我跑了npm install prop-types --save-dev
并开始收到此错误
'prop-types' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
Later I uninstalled the dependency by running npm uninstall prop-types --save-dev
and installed again by running npm install prop-types --save
后来我通过运行npm uninstall prop-types --save-dev
卸载了依赖项,并通过运行npm install prop-types --save
再次安装
Still the error doesn't go错误仍然没有 go
'prop-types' should be listed in the project's dependencies. Run 'npm i -S prop-types' to add it import/no-extraneous-dependencies
Your package.json will look something like你的 package.json 看起来像
{
"name": "your-website",
...
"dependencies": {
"react": "^16.10.2",
"react-dom": "^16.10.2",
"webpack": "^4.44.1",
...
},
"devDependencies": {
"prop-types": "^15.7.2",
"@types/node": "^14.0.18",
...
},
}
Make it look like让它看起来像
{
"name": "your-website",
...
"dependencies": {
"react": "^16.10.2",
"react-dom": "^16.10.2",
"webpack": "^4.44.1",
"prop-types": "^15.7.2",
...
},
"devDependencies": {
"@types/node": "^14.0.18",
...
},
}
by moving prop-types from devDependencies
to dependencies
通过将 prop-types 从devDependencies
移动到dependencies
项
After this, run npm install
or yarn install
if you are using yarn之后,运行npm install
或yarn install
如果你正在使用 yarn
Your devDependencies are the ones that are used while building your project.您的 devDependencies 是在构建项目时使用的那些。 They are not present in the production of your project.它们不存在于您的项目的生产中。 When someone opens a website in a browser the code for the devDependencies is not in it当有人在浏览器中打开网站时,devDependencies 的代码不在其中
When you install a package, if you just use npm install
it will put the package in your package.json
as a dependency
. When you install a package, if you just use npm install
it will put the package in your package.json
as a dependency
. If you use npm install --save-dev
it will put the package in your package.json
as a devDependency
如果您使用npm install --save-dev
它会将devDependency
放入您的package.json
You should execute this command: rm -rfd./node_modules
to delete node_modules directory and then change your package.json manually like this:您应该执行以下命令: rm -rfd./node_modules
删除 node_modules 目录,然后像这样手动更改 package.json :
"dependencies": {
...
"prop-types": <YOUR_VERSION>,
},
"devDependencies": {
...
},
and finally, run npm i
or yarn
if you're using yarn.最后,运行npm i
或yarn
如果您使用的是纱线。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.