简体   繁体   English

NPM错误找不到当前的“ es2015”-babel / node / react

[英]NPM error can't find present “es2015” - babel/node/react

I'm getting the following NPM error when I deploy to Heroku. 部署到Heroku时出现以下NPM错误。 My project is a mern stack . 我的项目是一个复杂的堆栈

Error: Couldn't find preset "es2015" relative to directory "/app" 错误:找不到相对于目录“ / app”的预设“ es2015”

在此处输入图片说明

Packages seem to be installed correctly, I have a .babelrc file set up correctly, and nothing is different locally compared to remote other than the parent directories are different. 软件包似乎安装正确,我已经正确设置了.babelrc文件,与父目录相比,本地与远程没有什么不同。 On Heroku, the parent directory is obviously "app". 在Heroku上,父目录显然是“ app”。 These are my NPM packages: 这些是我的NPM软件包:

  "dependencies": {
    "babel-core": "^6.7.2",
    "babel-polyfill": "^6.7.4",
    "body-parser": "~1.12.0",
    "cookie-parser": "~1.3.4",
    "css-modules-require-hook": "^4.0.0",
    "debug": "~2.1.1",
    "express": "~4.12.2",
    "react": "^0.14.7",
    "react-dom": "^0.14.7",
    "react-redux": "^4.4.1",
    "react-router": "^2.0.1",
    "redux": "^3.3.1",
    "serve-favicon": "~2.2.0",
    "webpack": "^1.12.13"
  },
  "devDependencies": {
    "babel-eslint": "^5.0.0",
    "babel-loader": "^6.2.4",
    "babel-plugin-react-transform": "^2.0.2",
    "babel-polyfill": "^6.7.4",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",
    "babel-preset-react-hmre": "^1.1.1",
    "babel-register": "^6.7.2",
    "css-modules-require-hook": "^4.0.0",
    "redux-devtools": "^3.1.1",
    "redux-devtools-dock-monitor": "^1.1.0",
    "redux-devtools-log-monitor": "^1.0.4",
    "webpack-dev-middleware": "^1.5.1",
    "webpack-hot-middleware": "^2.10.0"
  }

Furthermore, npm start runs index.js which consists of the following: 此外, npm start运行index.js ,其中包含以下内容:

require('babel-core/register');
require('babel-polyfill');
require('css-modules-require-hook');
require('./server/index');

I actually was getting errors with babel-polyfill and css-modules-require-hook not being found or something (I can't remember unfortunately) but when I added them from my devDependencies to my dependencies, it seemed to resolve itself. 我实际上因找不到babel-polyfillcss-modules-require-hook而出错(不幸的是,我不记得了),但是当我将它们从我的devDependencies添加到我的依赖项时,它似乎可以自行解决。 It's rather difficult to determine what packages to put where actually (any tips?). 确定将哪些程序包实际放置在何处相当困难(有什么技巧?)。 I'd really appreciate some direction! 我非常感谢您的指导!

From what i understand, heroku defaults to adding the --production flag, which inturn doesnt install your devdependencies. 据我了解,heroku默认添加--production标志,这反过来不会安装您的devdependencies。 I'd move all necessary dependencies to create your build to devDep to dependencies. 我将所有必要的依赖项移至创建devDep的依赖项。 or 要么

heroku config:set NPM_CONFIG_PRODUCTION=false

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

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