简体   繁体   English

找不到模块'babel-plugin-transform-decorators-legacy'

[英]Cannot find module 'babel-plugin-transform-decorators-legacy'

After npm run eject (this was needed in order to change the webpack.config), I've run into the following problem during the app compilation: Cannot find module 'babel-plugin-transform-decorators-legacy' .npm run eject后(这是更改 webpack.config 所必需的),我在应用程序编译过程中遇到了以下问题: Cannot find module 'babel-plugin-transform-decorators-legacy'

I've tried multiple variants that are described here: Cannot find module '@babel/plugin-transform-react-jsx-source' when running React App我尝试了这里描述的多种变体: 运行 React App 时找不到模块'@babel/plugin-transform-react-jsx-source'

(one of the most popular was to delete node modules and do yarn install again - it didn't help) (最流行的方法之一是删除节点模块并再次yarn install - 它没有帮助)

What could be done to fix that issue?可以做些什么来解决这个问题?

Here is my .babelrc file:这是我的.babelrc文件:

{
  "presets": [
    [
      "es2015",
      {
        "modules": false
      }
    ],
    "react",
    "stage-2",
    "react-app",
    "babel-preset-expo"
  ],
  "plugins": [
    "syntax-dynamic-import",
    "transform-decorators-legacy",
    "transform-object-rest-spread",
    "react-hot-loader/babel"
  ],
  "env": {
    "test": {
      "plugins": [
        "transform-decorators-legacy",
        "transform-object-rest-spread",
        "istanbul"
      ]
    }
  }
}

And my package.json :还有我的package.json

{
  "name": "maperclip-react",
  "version": "3.0.2",
  "private": true,
  "proxy": "http://maperclip-server:3001",
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js",
    "lint": "./node_modules/.bin/eslint ."
  },
  "dependencies": {
    "@amcharts/amcharts4": "^4.4.10",
    "@amcharts/amcharts4-geodata": "^4.1.5",
    "@babel/core": "7.6.0",
    "@babel/plugin-transform-react-jsx": "^7.7.0",
    "@babel/runtime": "^7.4.5",
    "@date-io/moment": "^1.3.6",
    "@material-ui/core": "^4.0.2",
    "@material-ui/icons": "^4.0.1",
    "@material-ui/styles": "^4.0.2",
    "@svgr/webpack": "4.3.2",
    "@typescript-eslint/eslint-plugin": "^2.2.0",
    "@typescript-eslint/parser": "^2.2.0",
    "array-move": "^2.1.0",
    "autosuggest-highlight": "^3.1.1",
    "axios": "^0.19.0",
    "babel-eslint": "10.0.3",
    "babel-jest": "^24.9.0",
    "babel-loader": "8.0.6",
    "babel-plugin-named-asset-import": "^0.3.4",
    "babel-preset-react-app": "^9.0.2",
    "babel-preset-stage-2": "^6.24.1",
    "bootstrap": "^4.3.1",
    "bootstrap-v4-rtl": "^4.3.1-3",
    "bpmn-js": "^4.0.4",
    "camelcase": "^5.2.0",
    "can-use-dom": "^0.1.0",
    "case-sensitive-paths-webpack-plugin": "2.2.0",
    "chart.js": "^2.8.0",
    "classnames": "^2.2.6",
    "connected-react-router": "^6.4.0",
    "cross-env": "^5.2.0",
    "css-loader": "2.1.1",
    "dotenv": "6.2.0",
    "dotenv-expand": "5.1.0",
    "dotenv-webpack": "^1.7.0",
    "downshift": "^3.2.10",
    "draft-js": "^0.10.5",
    "draftjs-to-html": "^0.8.4",
    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-config-react-app": "^5.0.2",
    "eslint-loader": "3.0.2",
    "eslint-plugin-flowtype": "3.13.0",
    "eslint-plugin-import": "2.18.2",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.14.3",
    "eslint-plugin-react-hooks": "^1.6.1",
    "file-loader": "3.0.1",
    "firebase": "^6.1.0",
    "fs-extra": "7.0.1",
    "history": "^4.9.0",
    "html-webpack-plugin": "4.0.0-beta.5",
    "identity-obj-proxy": "3.0.0",
    "install": "^0.12.2",
    "is-wsl": "^1.1.0",
    "isomorphic-fetch": "^2.2.1",
    "jest": "24.9.0",
    "jest-environment-jsdom-fourteen": "0.1.0",
    "jest-resolve": "24.9.0",
    "jest-watch-typeahead": "0.4.0",
    "jquery": "^3.4.1",
    "jquery-ui": "^1.12.1",
    "jss-rtl": "^0.2.3",
    "material-ui-pickers": "^2.2.4",
    "mini-css-extract-plugin": "0.8.0",
    "moment": "^2.24.0",
    "node-sass": "^4.12.0",
    "nprogress": "^0.2.0",
    "optimize-css-assets-webpack-plugin": "5.0.3",
    "path": "^0.12.7",
    "pnp-webpack-plugin": "1.5.0",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-normalize": "7.0.1",
    "postcss-preset-env": "6.7.0",
    "postcss-safe-parser": "4.0.1",
    "prettier": "^1.17.1",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-app-polyfill": "^1.0.4",
    "react-autosuggest": "^9.4.3",
    "react-big-calendar": "^0.21.0",
    "react-bootstrap-sweetalert": "^4.4.1",
    "react-chartjs-2": "^2.7.6",
    "react-circular-progressbar": "^2.0.1",
    "react-ckeditor-component": "^1.1.0",
    "react-color": "^2.17.3",
    "react-custom-scrollbars": "^4.2.1",
    "react-d3-speedometer": "^0.5.5",
    "react-dev-utils": "^9.1.0",
    "react-device-detect": "^1.6.2",
    "react-dnd": "^7.4.5",
    "react-dnd-html5-backend": "^7.4.4",
    "react-dom": "^16.8.6",
    "react-draft-wysiwyg": "^1.13.2",
    "react-dropzone": "^10.1.5",
    "react-google-maps": "^9.4.5",
    "react-hot-loader": "^4.9.0",
    "react-icons": "^3.7.0",
    "react-intl": "^2.9.0",
    "react-joyride": "^2.0.5",
    "react-jvectormap": "^0.0.12",
    "react-load-script": "^0.0.6",
    "react-loadable": "^5.5.0",
    "react-notifications": "^1.4.3",
    "react-number-format": "^4.0.8",
    "react-placeholder": "^3.0.2",
    "react-redux": "^7.0.3",
    "react-router": "^5.0.1",
    "react-router-dom": "^5.0.1",
    "react-select": "^3.0.4",
    "react-simple-maps": "^0.12.1",
    "react-slick": "^0.24.0",
    "react-sortable-hoc": "^1.9.1",
    "react-star-rating-component": "^1.4.1",
    "react-swipeable-views": "^0.13.3",
    "react-text-mask": "^5.4.3",
    "reactstrap": "^8.0.0",
    "recharts": "^1.6.2",
    "recompose": "^0.30.0",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-saga": "^1.0.2",
    "resolve": "1.12.0",
    "resolve-url-loader": "3.1.0",
    "sass-loader": "7.2.0",
    "save": "^2.4.0",
    "semver": "6.3.0",
    "slick-carousel": "^1.8.1",
    "style-loader": "1.0.0",
    "terser-webpack-plugin": "1.4.1",
    "ts-pnp": "1.1.4",
    "typeface-roboto": "^0.0.54",
    "url-loader": "2.1.0",
    "url-search-params": "^1.1.0",
    "uuid": "^3.3.3",
    "webpack": "4.41.0",
    "webpack-dev-server": "3.2.1",
    "webpack-manifest-plugin": "2.1.1",
    "workbox-webpack-plugin": "4.3.1"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "jest": {
    "roots": [
      "<rootDir>/src"
    ],
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,ts,tsx}",
      "!src/**/*.d.ts"
    ],
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "setupFilesAfterEnv": [],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
      "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
    ],
    "testEnvironment": "jest-environment-jsdom-fourteen",
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "modulePaths": [
      "/Users/ivan/MyCubes/MaperClip_Athlon/Maperclip/client_react/src"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "web.ts",
      "ts",
      "web.tsx",
      "tsx",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ],
    "watchPlugins": [
      "jest-watch-typeahead/filename",
      "jest-watch-typeahead/testname"
    ]
  }
}

UPDATE更新

I've also done yarn add babel-plugin-transform-decorators-legacy - it didn't work.我还完成了yarn add babel-plugin-transform-decorators-legacy - 它没有用。

You are using @babel v7 but babel-plugin-transform-decorators-legacy is a plugin for babel 6 .您正在使用@babel v7babel-plugin-transform-decorators-legacybabel 6的插件。

You should use @babel/plugin-proposal-decorators .你应该使用@babel/plugin-proposal-decorators

More info at https://www.npmjs.com/package/babel-plugin-transform-decorators-legacy更多信息在https://www.npmjs.com/package/babel-plugin-transform-decorators-legacy

(...)
"plugins": [
  "syntax-dynamic-import",
  ["@babel/plugin-proposal-decorators", { "legacy": true }],
  "@babel/plugin-proposal-object-rest-spread",
  "react-hot-loader/babel"
]
(...)

and

npm i @babel/plugin-proposal-object-rest-spread @babel/plugin-proposal-decorators

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:无法从“/home/dolphin/sync/source/cruise-web”找到模块“@babel/plugin-proposal-decorators” - Error: Cannot find module '@babel/plugin-proposal-decorators' from '/home/dolphin/sync/source/cruise-web' 如何在Babel + transform-decorators-legacy中禁用定义类的属性 - How to disable defining class properties in Babel + transform-decorators-legacy 运行 React App 时找不到模块“@babel/plugin-transform-react-jsx-source” - Cannot find module '@babel/plugin-transform-react-jsx-source' when running React App 如何使用 babel 遗留装饰器 - how to use babel legacy decorators 未找到兼容版本:babel-plugin-transform-decorators@^6.13.0 - No compatible version found: babel-plugin-transform-decorators@^6.13.0 错误:找不到模块“@babel/plugin-proposal-class-properties” - Error: Cannot find module '@babel/plugin-proposal-class-properties' 使用 Firebase 在 CodeSandbox 上找不到/安装 babel 插件“proposal-decorators” - Could not find/install babel plugin 'proposal-decorators' on CodeSandbox with Firebase 找不到模块'@babel/parser' - Cannot find module '@babel/parser' 在Windows中使用react storybook时出现未知插件“transform-decorators-legacy”错误 - Unknown plugin “transform-decorators-legacy” error when using react storybook in windows React Native Typescript babel-plugin-module-resolver 错误:找不到模块或其对应的类型声明 - React Native Typescript babel-plugin-module-resolver error: Cannot find module or its corresponding type declerations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM