部署到Heroku时,我收到以下NPM错误。我的项目是mern stack。
错误:无法找到预设" es2015"相对于目录" / app"
软件包似乎安装正确,我正确设置了.babelrc文件,除了父目录不同之外,与远程软件相比,本地没有任何区别。在Heroku上,父目录显然是" app"。这些是我的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"
}
此外,npm start
运行 index.js ,其中包含以下内容:
require('babel-core/register');
require('babel-polyfill');
require('css-modules-require-hook');
require('./server/index');
我实际上遇到的错误是找不到babel-polyfill
和css-modules-require-hook
或其他东西(我不记得不幸)但是当我从devDependencies添加它们到我的依赖项时,它似乎解决自己。要确定实际放置哪些包(任何提示?)相当困难。我非常欣赏一些方向!
答案 0 :(得分:4)
据我所知,heroku默认添加--production标志,这不会安装你的devdependencies。我移动所有必要的依赖项来创建devDep依赖项的构建。 或
heroku config:set NPM_CONFIG_PRODUCTION=false