尽管未在package.json中显示,create-react-app使用模块

时间:2018-10-11 23:19:49

标签: reactjs npm

据我了解,create-react-app命令安装了我们入门所需的所有内容,以及更多内容。我目前正在尝试使ESLint AirBnB和Prettier正常工作,而eslint需要很多依赖项。

浏览我的node_modules时,我注意到列出了eslint-config-airbnbeslint-config-airbnb-base。在package.json中,我"eslint-config-airbnb": "^17.1.0",列出了

如果我错了,请纠正我,但是我现在的假设是,尽管没有在package.json中列出所有具有对等依赖性的包,但它们仍然可以正常工作。这是基于create-react-app来向我们隐藏大多数配置吗?您还可以提供有关该主题的其他任何信息吗?

以上模块和依赖项实际上仅代表整个理论问题。我以eslint config为例。

欢呼

编辑:我使用了eslint示例,因为我确实有一个问题,即它不能正确加载,也不能正确掉毛。我通过将.eslintrrc.js从项目目录移到父目录来解决了该问题。为什么这样有效,我不知道

1 个答案:

答案 0 :(得分:0)

这是弹出CRA时的所有依赖项(因此我猜测是的,您将需要安装它,因为两者均未列出)

"dependencies": {
    "@babel/core": "7.1.0",
    "@svgr/webpack": "2.4.1",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "9.0.0",
    "babel-jest": "23.6.0",
    "babel-loader": "8.0.4",
    "babel-plugin-named-asset-import": "^0.2.2",
    "babel-preset-react-app": "^5.0.2",
    "bfj": "6.1.1",
    "case-sensitive-paths-webpack-plugin": "2.1.2",
    "chalk": "2.4.1",
    "css-loader": "1.0.0",
    "dotenv": "6.0.0",
    "dotenv-expand": "4.2.0",
    "eslint": "5.6.0",
    "eslint-config-react-app": "^3.0.3",
    "eslint-loader": "2.1.1",
    "eslint-plugin-flowtype": "2.50.1",
    "eslint-plugin-import": "2.14.0",
    "eslint-plugin-jsx-a11y": "6.1.1",
    "eslint-plugin-react": "7.11.1",
    "file-loader": "2.0.0",
    "fs-extra": "7.0.0",
    "html-webpack-plugin": "4.0.0-alpha.2",
    "identity-obj-proxy": "3.0.0",
    "jest": "23.6.0",
    "jest-pnp-resolver": "1.0.1",
    "jest-resolve": "23.6.0",
    "mini-css-extract-plugin": "0.4.3",
    "optimize-css-assets-webpack-plugin": "5.0.1",
    "pnp-webpack-plugin": "1.1.0",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-preset-env": "6.0.6",
    "postcss-safe-parser": "4.0.1",
    "react": "^16.5.2",
    "react-app-polyfill": "^0.1.3",
    "react-dev-utils": "^6.0.3",
    "react-dom": "^16.5.2",
    "resolve": "1.8.1",
    "sass-loader": "7.1.0",
    "style-loader": "0.23.0",
    "terser-webpack-plugin": "1.1.0",
    "url-loader": "1.1.1",
    "webpack": "4.19.1",
    "webpack-dev-server": "3.1.9",
    "webpack-manifest-plugin": "2.0.4",
    "workbox-webpack-plugin": "3.6.2"
  },

请注意,您可能希望脱离CRA并构建自己的Webpack。 :)

否则,您很有可能会遇到更严重的问题。