ERROR in ./node_modules/babel-core/lib/helpers/resolve.js When trying to build from webpack

645 Views Asked by At

I am getting this error when I install babel-core in dependencies, If I Install babel-core in Devdependencies it works, but I need babel-core in dependencies, How to surpass this issue? Is there a way in which I can install Babel-core in Dependencies and not get this error?

ERROR in ./node_modules/babel-core/lib/helpers/resolve.js
Module not found: Error: Can't resolve 'module' in '/app/node_modules/babel-core/lib/helpers'
 @ ./node_modules/babel-core/lib/helpers/resolve.js 34:14-31
 @ ./node_modules/babel-core/lib/transformation/file/options/build-
   configchain.js

This is my webpack config.dll file,

How to go by this issue?

const os = require('os');
const path = require('path');
const webpack = require('webpack');
const HappyPack = require('happypack');
const paths = require('./paths');

const vendors = Object.keys(require(path.join(__dirname, '../package')).dependencies); // eslint-disable-line
let outputPath = path.join(__dirname, '..', 'dev', 'static', 'js');

if (process.env.NODE_ENV === 'production') {
  outputPath = path.join(__dirname, '..', 'build', 'static', 'js');
}

const config = {
  node: {
    dgram: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
  },
  entry: {
    vendor: vendors,
  },
  output: {
    path: outputPath,
    filename: '[name].dll.js',
    library: '[name]_[hash]',
    publicPath: '/static/js/',
  },
  plugins: [
    new HappyPack({
      loaders: ['babel-loader'],
      threads: process.env.BUILD_CPUS ? parseInt(process.env.BUILD_CPUS) : ((os.cpus().length - 1) || 1),
    }),
    new webpack.DllPlugin({
      path: path.join(__dirname, '..', 'config', '[name]-manifest.json'),
      name: '[name]_[hash]',
      context: path.resolve(__dirname),
    }),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production'),
      },
    }),
  ],
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.join(__dirname, '../node_modules/nested-set'),
        loader: 'happypack/loader',
      },
    ],
  },
  resolve: {
    modules: ['node_modules'],
    extensions: ['.js', '.json'],
    alias: {
      react: path.join(paths.appNodeModules, '/react'),
      'react-dom': path.join(paths.appNodeModules, '/react-dom'),
    },
  },
};


if (process.env.NODE_ENV === 'production') {
  config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}

module.exports = config;

And these are my dependencies,

"devDependencies": {
    "add-asset-html-webpack-plugin": "^2.0.1",
    "amdefine": "^1.0.1",
    "autoprefixer": "6.7.*",
    "babel-eslint": "^7.2.3",
    "babel-jest": "^20.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-dynamic-import-webpack": "^1.0.1",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-app": "2.2.*",
    "babel-preset-stage-0": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "babel-runtime": "^6.23.0",
    "case-sensitive-paths-webpack-plugin": "^2.1.1",
    "chalk": "1.1.*",
    "connect-history-api-fallback": "1.3.*",
    "cpr": "^2.2.0",
    "cross-spawn": "4.0.*",
    "css-loader": "0.26.*",
    "detect-port": "1.1.*",
    "dotenv": "^4.0.0",
    "eslint": "3.19.*",
    "eslint-config-airbnb": "14.1.*",
    "eslint-config-react-app": "0.6.*",
    "eslint-loader": "1.6.*",
    "eslint-plugin-flowtype": "2.21.*",
    "eslint-plugin-import": "2.2.*",
    "eslint-plugin-jsx-a11y": "4.0.*",
    "eslint-plugin-react": "6.10.*",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "0.10.*",
    "fs-extra": "0.30.*",
    "happypack": "^4.0.0-beta.1",
    "has-flag": "^2.0.0",
    "html-webpack-plugin": "^2.29.0",
    "http-proxy-middleware": "0.17.*",
    "jest": "^20.0.4",
    "json-loader": "0.5.*",
    "locate-path": "^2.0.0",
    "object-assign": "4.1.*",
    "postcss-loader": "1.2.*",
    "preload-webpack-plugin": "^1.2.2",
    "promise": "7.1.*",
    "react-dev-utils": "^3.0.2",
    "react-error-overlay": "^1.0.9",
    "style-loader": "0.13.*",
    "url-loader": "0.5.*",
    "webpack": "^3.1.0",
    "webpack-dev-server": "^2.5.1",
    "whatwg-fetch": "2.0.2"
  },
  "dependencies": {
    "ajv": "4.10.0",
    "babel-core": "^6.26.0",
    "babel-polyfill": "^6.26.0",
    "copy-to-clipboard": "3.0.*",
    "core-js": "^2.5.1",
    "downloadjs": "1.4.*",
    "es-abstract": "^1.7.0",
    "function-bind": "^1.1.0",
    "has": "^1.0.1",
    "html2canvas": "^0.5.0-beta4",
    "jspdf": "^1.3.5",
    "marked": "0.3.3",
    "marksy": "5.0.*",
    "material-ui": "0.18.*",
    "moment": "2.18.1",
    "nested-set": "^1.0.0-rc0",
    "object.entries": "^1.0.4",
    "pdfjs-dist": "^1.9.528",
    "prop-types": "15.5.1*",
    "react": "15.4.*",
    "react-cellblock": "3.0.*",
    "react-chatview": "0.2.*",
    "react-code-splitting": "^1.1.1",
    "react-datepicker": "0.52.0",
    "react-dom": "15.4.*",
    "react-infinite": "^0.12.1",
    "react-intl": "2.3.*",
    "react-joyride": "1.11.*",
    "react-pdf": "^2.0.0",
    "react-redux": "5.0.*",
    "react-router": "4.0.*",
    "react-router-dom": "4.0.*",
    "react-sortable-tree": "^1.5.3",
    "react-tap-event-plugin": "2.0.*",
    "react-virtualized": "^9.9.0",
    "react-visibility-sensor": "^3.10.1",
    "redux": "3.6.*",
    "striptags": "2.2.1",
    "url-parse": "^1.1.9",
    "uuid": "^3.1.0"
  },
0

There are 0 best solutions below