Reputation: 42604
I am using webpack to manage a react+redux web application. When I run webpack command, I got below error:
node_modules/npm-install-webpack-plugin/src/installer.js:82
var options = Object.assign({
^
TypeError: Object function Object() { [native code] } has no method 'assign'
at Object.checkBabel (/var/lib/jenkins/jobs/Go2nurse Web Build/workspace/app/src/main/webres/node_modules/npm-install-webpack-plugin/src/installer.js:82:24)
at new NpmInstallPlugin (/var/lib/jenkins/jobs/Go2nurse Web Build/workspace/app/src/main/webres/node_modules/npm-install-webpack-plugin/src/plugin.js:36:13)
at Object.<anonymous> (/var/lib/jenkins/jobs/Go2nurse Web Build/workspace/app/src/main/webres/webpack.config.dev.js:93:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/jenkins/jobs/Go2nurse Web Build/workspace/app/src/main/webres/webpack.config.js:9:20)
below is my webpack config file:
const webpack = require('webpack');
const path = require('path');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
var CompressionPlugin = require("compression-webpack-plugin");
const PATHS = {
react: path.join(__dirname, 'node_modules', 'react', 'dist', 'react.min.js'),
app: path.join(__dirname, 'src'),
build: path.join(__dirname, './dist')
};
module.exports = {
entry: {
app: './app/index.jsx',
android: './app/utils/platform_android.js',
ios: './app/utils/platform_ios.js',
web: './app/utils/platform_web.js',
vendor: [
'axios',
'react',
'react-dom',
'react-redux',
'react-router',
'react-router-redux',
'redux',
'redux-thunk',
'react-alert',
'sha1',
'moment',
'nuka-carousel',
'react-cookie',
'material-ui',
'react-spinkit',
'react-tap-event-plugin',
'react-tappable',
'history',
],
},
output: {
path: PATHS.build,
filename: '[name].bundle.js',
},
watch: true,
devtool: 'source-map',
relativeUrls: true,
resolve: {
extensions: ['', '.js', '.jsx', '.css', '.less'],
modulesDirectories: ['node_modules'],
alias: {
normalize_css: __dirname + '/node_modules/normalize.css/normalize.css',
}
},
module: {
preLoaders: [
{
test: /\.js$/,
loader: "source-map-loader"
},
],
loaders: [
{
test: /\.html$/,
loader: 'file?name=[name].[ext]',
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader?presets=es2015',
},
{
test: /\.less$/,
loader: "style!css!less",
},
{test: /\.css$/, loader: 'style-loader!css-loader'},
{test: /\.png$/, loader: "url-loader?limit=100000"},
// {test: /\.(jpe?g|png|gif|svg)$/i, loader: "file-loader?name=/public/icons/[path]/[name].[ext]"},
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel-loader?presets=es2015']
},
{
test: /\.svg$/,
loader: 'svg-sprite',
include: /public\/icons/
}
]
},
plugins: [
new NpmInstallPlugin({
save: true // --save
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("development")
}
}),
new WebpackShellPlugin({
onBuildStart: ['echo "Webpack Start"'],
onBuildEnd: ['cp ./dist/*.js ../assets/dist/',
'rm -r dist/web',
'mkdir -p dist/web/dist',
'cp ./dist/*.js ./dist/web/dist/',
'cp ./index.html ./dist/web/']
}),
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */["vendor"], /* filename= */"[name].bundle.js", Infinity),
],
devServer: {
colors: true,
contentBase: __dirname,
historyApiFallback: true,
hot: true,
inline: true,
port: 9093,
progress: true,
stats: {
cached: false
}
}
}
I don't understand what wrong with my configuration. Why does webpack complain Object.assign() function. Does it have anything to do with the version?
Upvotes: 0
Views: 554
Reputation: 1159
Object.assign is a method on es2015 version, you most likely don't have the latest version of node.js. Try upgrading node.js to the latest version
Upvotes: 1