我正在尝试在Heroku上部署,在那里我得到了以下错误:remote: Failed to minify the code from this file:
remote: ./node_modules/webhoseio/webhoseio.js:13
在检查这个依赖关系时,我发现它使用了ES5'use strict';
声明。如何让Heroku编译此依赖项?
EDIT:Package.json文件{
"name": "stocks-app",
"version": "1.0.0",
"description": "Mern Demo",
"main": "server.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "babel-node server.js",
"start:dev": "concurrently "nodemon --ignore 'client/*'" "npm run client"",
"client": "cd client && npm run start",
"install": "cd client && yarn install",
"build": "cd client && npm run build",
"heroku-postbuild": "npm run build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"concurrently": "^4.1.0",
"nodemon": "^1.18.9"
},
"dependencies": {
"alphavantage": "^1.2.0",
"axios": "^0.18.0",
"brain.js": "^1.6.0",
"cors": "^2.8.5",
"dotenv": "^6.2.0",
"express": "^4.16.3",
"if-env": "^1.0.4",
"mdbreact": "^4.8.5-patch.1",
"mongoose": "^5.4.0",
"newsapi": "^2.4.0",
"request": "^2.88.0",
"webhoseio": "^1.0.2"
}
}
我通过在Webpack配置中关闭缩小来解决这个问题。我没有使用CRA预配置的Webpack ES Lint加载程序,而是安装了HTML加载程序并将loader
设置为该加载程序。接下来,我将最小化设置为false
。方法如下:
module: {
rules: [
{
use: [
{
options: {
formatter: eslintFormatter,
eslintPath: require.resolve('eslint'),
minimize: false,
},
loader: require.resolve('html-loader'),
},
],}}