致命错误:CALL_AND_RETRY_LAST分配失败 - JavaScript堆内存不足?

时间:2018-04-19 14:02:22

标签: reactjs webpack ecmascript-6 babel-loader babel-core

当我使用 webpack 构建系统编译时,JavaScript内存不足。我不知道是什么问题。 Snapshot of error while on npm run build:prod 我正在使用:

操作系统:Ubuntu 16.04, 内存:8Gig, 处理器:Inter Core-i5

Node.js,babel-minify-webpack-plugin。 Reactjs 16.2和Redux

这是Webpack.config.js文件:

var webpack = require('webpack');
var path = require('path');
const env = process.env.NODE_ENV || 'development'
const MinifyPlugin = require("babel-minify-webpack-plugin");

module.exports = {
  entry: {
    '/js/app': './frontend/app.js'
  },
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'public')
  },
  module: {
    rules: [
      {
        test: /\.(scss|css|sass)$/i,
        use: [{
          loader: "style-loader"
        }, {
          loader: "css-loader"
        }, {
          loader: "sass-loader",
          options: {
            includePaths: [
              path.resolve("./node_modules/")
            ]
          }
        }]
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: path.join(__dirname, "frontend"),
        exclude: path.resolve(__dirname, "node_modules"),
        query: {
        presets: ['es2015', 'react']
        }
      },
      {
        test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
        loader: 'url-loader?limit=4096&name=[name]-[hash].[ext]'
      },
      {
        test: /\.json$/,
        loader: 'json-loader'
      }
    ]
  },
  externals: {
    jquery: 'jQuery'
  },
  node: {
    fs: "empty",
    net: "empty"
  },
  plugins: [
    new webpack.ProvidePlugin({
      'videojs': 'video.js',
      'window.videojs': 'video.js'
    }),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('production')
    }),
    new MinifyPlugin(true, true)
  ]
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

这是我的package.json文件:

{
  "name": "node-ejs",
  "version": "1.0.0",
  "description": "this is our first app using nodejs on express server with babel",
  "main": "server.js",
  "proxy": "http://10.1.0.7",
  "scripts": {
    "start": "nodemon ./server.js --exec babel-node --presets env",
    "build:debug": "webpack -d --progress --colors",
    "build:prod": "webpack -p --progress --colors",
    "build": "webpack --config webpack.config.js"
  },
  "keywords": [
    "nodejs",
    "babel",
    "express"
  ],
  "watch": true,
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@blueprintjs/core": "^1.35.0",
    "axios": "^0.17.1",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-plugin-minify-builtins": "^0.4.0",
    "babel-plugin-minify-flip-comparisons": "^0.4.0",
    "babel-preset-es2015": "^6.24.1",
    "body-parser": "^1.18.2",
    "bootstrap": "^3.3.7",
    "ejs": "^2.5.7",
    "express": "^4.16.2",
    "express-ejs-extend": "0.0.1",
    "firebase": "^4.8.2",
    "js-file-download": "^0.4.1",
    "json-loader": "^0.5.7",
    "material-design-icons": "^3.0.1",
    "moment": "^2.22.0",
    "node-sass": "^4.7.2",
    "nodemon": "^1.14.5",
    "npm": "^5.8.0",
    "npm-install-peers": "^1.2.1",
    "pure-render-decorator": "^1.2.1",
    "query-string": "^6.0.0",
    "re-base": "^3.2.2",
    "react-addons-css-transition-group": "^15.6.2",
    "react-bootstrap": "^0.31.5",
    "react-breadcrumbs-dynamic": "^1.0.12",
    "react-dom": "^16.2.0",
    "react-file-download": "^0.3.5",
    "react-jplayer": "^7.1.2",
    "react-notifications": "^1.4.3",
    "react-owl-carousel2": "^0.2.1",
    "react-pager": "^1.3.3",
    "react-placeholder": "^2.0.0",
    "react-redux": "^5.0.6",
    "react-rev-slider": "^1.0.1",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^4.0.8",
    "react-share": "^1.19.0",
    "react-slick": "^0.20.0",
    "redux": "^3.7.2",
    "redux-promise-middleware": "^5.0.0",
    "redux-thunk": "^2.2.0",
    "sass-loader": "^6.0.6",
    "save-dev": "^2.0.0",
    "scss-loader": "0.0.1",
    "slick-carousel": "^1.8.1",
    "update": "^0.7.4",
    "video.js": "^6.6.0",
    "videojs-contrib-dash": "^2.9.2",
    "videojs-ima": "^1.0.1",
    "webpack": "^3.10.0",
    "webpack-dev-server": "^2.9.7"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.0.0-beta.44",
    "babel-cli": "^6.26.0",
    "babel-minify": "^0.4.0",
    "babel-minify-webpack-plugin": "^0.3.1",
    "babel-preset-env": "^1.6.1",
    "babel-preset-minify": "^0.4.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-1": "^6.24.1",
    "babel-register": "^6.26.0",
    "css-loader": "^0.28.7",
    "file-loader": "^1.1.6",
    "img-loader": "^2.0.0",
    "jquery": "^3.2.1",
    "lodash": "^4.17.4",
    "postcss-loader": "^2.0.10",
    "react": "^16.2.0",
    "react-dfp": "^0.7.0",
    "react-modal": "^3.1.10",
    "react-router-bootstrap": "^0.24.4",
    "style-loader": "^0.19.1",
    "url-loader": "^0.6.2"
  }
}

0 个答案:

没有答案