简体   繁体   中英

Cannot find module '@babel/plugin-proposal-decorators' from '/app'

My application perfectly running and building on localhost. But when it's building on Heroku, I'm getting the following error:

./src/index.js
Error: Cannot find module '@babel/plugin-proposal-decorators' from '/app'
    at Array.map (<anonymous>)

That's my package.json :

{
  "name": "agroproject-ui",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@ckeditor/ckeditor5-build-classic": "^12.0.0",
    "@ckeditor/ckeditor5-react": "^1.1.1",
    "@fortawesome/fontawesome-svg-core": "^1.2.8",
    "@fortawesome/free-solid-svg-icons": "^5.5.0",
    "@fortawesome/react-fontawesome": "^0.1.3",
    "@pluralsight/ps-design-system-actionmenu": "^3.1.10",
    "@pluralsight/ps-design-system-badge": "^2.1.12",
    "@pluralsight/ps-design-system-button": "^10.8.15",
    "@pluralsight/ps-design-system-card": "^8.5.8",
    "@pluralsight/ps-design-system-dropdown": "^0.5.3",
    "@pluralsight/ps-design-system-layout": "^3.0.2",
    "@pluralsight/ps-design-system-normalize": "^3.0.45",
    "@pluralsight/ps-design-system-row": "^2.6.25",
    "@pluralsight/ps-design-system-textinput": "^0.5.6",
    "@svgr/webpack": "2.4.1",
    "@tinymce/tinymce-react": "^3.0.1",
    "axios": "^0.18.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.4",
    "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.4",
    "eslint-loader": "2.1.1",
    "eslint-plugin-flowtype": "2.50.1",
    "eslint-plugin-import": "2.14.0",
    "eslint-plugin-jsx-a11y": "6.1.2",
    "eslint-plugin-react": "7.11.1",
    "file-loader": "2.0.0",
    "fs-extra": "7.0.0",
    "glamor": "^2.20.40",
    "google-maps-react": "^2.0.2",
    "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",
    "jsonwebtoken": "^8.4.0",
    "mini-css-extract-plugin": "0.4.3",
    "node-sass": "^4.9.4",
    "optimize-css-assets-webpack-plugin": "5.0.1",
    "pnp-webpack-plugin": "1.1.0",
    "postcss-cssnext": "^3.1.0",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-import": "^12.0.0",
    "postcss-loader": "3.0.0",
    "postcss-preset-env": "6.0.6",
    "postcss-safe-parser": "4.0.1",
    "prop-types": "^15.6.2",
    "react": "^16.5.2",
    "react-app-polyfill": "^0.1.3",
    "react-aux": "^1.1.0",
    "react-dev-utils": "^6.0.5",
    "react-dom": "^16.5.2",
    "react-redux": "^6.0.0",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-table": "^6.8.6",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0",
    "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.2.1",
    "webpack-manifest-plugin": "2.0.4",
    "workbox-webpack-plugin": "3.6.2"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "resolver": "jest-pnp-resolver",
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx}"
    ],
    "testEnvironment": "jsdom",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.4.3",
    "@babel/plugin-proposal-class-properties": "^7.4.0",
    "@babel/plugin-proposal-decorators": "^7.4.0",
    "@babel/preset-env": "^7.1.6",
    "redux-devtools": "^3.4.2",
    "redux-devtools-extension": "^2.13.7",
    "stylelint-config-airbnb": "0.0.0"
  }

Any idea what could possibly is wrong with package.json ?

You have included @babel/plugin-proposal-decorators in your devDependencies .

By default , Heroku installs your dependencies and devDependencies , builds your slug, and then strips out your devDependencies . This makes sense: in most cases devDependencies shouldn't be on production; that's for things like testing frameworks, editor plugins, etc. that you need in development but not in production.

I recommend moving this module to your dependencies , though an alternative solution would be to tell Heroku not to prune your devDependencies by setting NPM_CONFIG_PRODUCTION=false or YARN_PRODUCTION=false , depending on the tool you're using.

Both approaches will require a redeploy to take effect, and unless you have a clear reason to use devDependencies on Heroku I urge you to use the former.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM