Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

javascript - '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

'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

Still the error doesn't go

'prop-types' should be listed in the project's dependencies. Run 'npm i -S prop-types' to add it import/no-extraneous-dependencies

question from:https://stackoverflow.com/questions/65866065/prop-types-should-be-listed-in-the-projects-dependencies-not-devdependencies

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your package.json will look something like

{
  "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

After this, run npm install or yarn install if you are using yarn


Your devDependencies are the ones that are used while building your project. 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


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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...