模块构建失败:ReferenceError:未知插件" import"在" base"中指定在0

时间:2017-03-11 05:12:12

标签: javascript reactjs webpack create-react-app antd

我正在使用ReactJS项目,我正在使用create-react-app,突然间我遇到了以下错误,我不知道为什么。在得到错误之前我记得我用过" yarn add react-rte"然后我意识到我并不需要它,所以我跑了"纱线去掉react-rte" 。之后,我的项目无法正常工作,每次启动项目时都会出现以下错误:Error in ./src/index.js Module build failed: ReferenceError: Unknown plugin "import" specified in "base" at 0, attempted to resolve relative to "projectFolder/src" at Array.map (native) @ multi main

的package.json

{
"name": "client",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "autoprefixer": "6.7.2",
    "babel-core": "6.22.1",
    "babel-eslint": "7.1.1",
    "babel-jest": "18.0.0",
    "babel-loader": "6.2.10",
    "babel-preset-react-app": "^2.1.0",
    "case-sensitive-paths-webpack-plugin": "1.1.4",
    "chalk": "1.1.3",
    "connect-history-api-fallback": "1.3.0",
    "cross-spawn": "4.0.2",
    "css-loader": "0.26.1",
    "detect-port": "1.0.1",
    "dotenv": "2.0.0",
    "eslint": "3.8.1",
    "eslint-config-react-app": "^0.5.1",
    "eslint-loader": "1.6.0",
    "eslint-plugin-flowtype": "2.21.0",
    "eslint-plugin-import": "2.0.1",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.4.1",
    "extract-text-webpack-plugin": "1.0.1",
    "file-loader": "0.10.0",
    "fs-extra": "0.30.0",
    "html-webpack-plugin": "2.24.0",
    "http-proxy-middleware": "0.17.3",
    "jest": "18.1.0",
    "json-loader": "0.5.4",
    "node-sass": "^3.13.0",
    "object-assign": "4.1.1",
    "postcss-loader": "1.2.2",
    "promise": "7.1.1",
    "react-dev-utils": "^0.5.0",
    "sass-loader": "^4.0.2",
    "style-loader": "0.13.1",
    "url-loader": "0.5.7",
    "webpack": "1.14.0",
    "webpack-dev-server": "1.16.2",
    "webpack-manifest-plugin": "1.1.0",
    "whatwg-fetch": "2.0.2"
  },
  "dependencies": {
    "antd": "^2.5.0",
    "axios": "^0.15.2",
    "moment-timezone": "^0.5.10",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-intl": "2.2.3",
    "react-redux": "^4.4.6",
    "react-router": "^3.0.0",
    "redux": "^3.6.0",
    "redux-form": "^6.5.0",
    "redux-thunk": "^2.1.0"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom"
  },
  "jest": {
    "moduleFileExtensions": [
      "jsx",
      "js",
      "json"
    ],
    "moduleNameMapper": {
      "^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/config/jest/FileStub.js",
      "^.+\\.css$": "<rootDir>/config/jest/CSSStub.js"
    },
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>/(build|docs|node_modules)/"
    ],
    "testEnvironment": "node"
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

非常感谢任何帮助。 谢谢。

1 个答案:

答案 0 :(得分:6)

请参阅:https://ant.design/docs/react/use-with-create-react-app

请确保您已安装babel-plugin-import

安装插件:

npm install babel-plugin-import --save-dev

或:

yarn add babel-plugin-import --dev