我正在建立我的第一个网站,并从其他人的反应模板开始。为了在Windows计算机上进行本地开发,我使用了“ npm start”,这很好。现在,我正在尝试在Linux机器上进行部署,但我只得到一个白页,并且我的react js文件未加载。
我现在正在尝试使用“ npm run build”,它正在启动生产配置(我没有写过),并且抛出了一个我不知道的错误。以下是我拥有的所有相关信息。有谁知道这可能是什么?我已经浪费了很多时间试图解决这个问题。
我尝试更新npm,重新安装节点模块,使用管理模式等。使用“ npm run build”时,该问题在我的Windows和Linux计算机上均会发生。
有什么建议吗?
ERROR in bundle2.js from UglifyJs
Invalid assignment [bundle2.js:15571,30]
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js?sourceMap&localIdentName=[local]___[hash:base64:5]!node_modules/sass-loader/lib/loader.js?outputStyle=expanded!app/styles/index.scss:
[0] ./node_modules/css-loader?sourceMap&localIdentName=[local]___[hash:base64:5]!./node_modules/sass-loader/lib/loader.js?outputStyle=expanded!./app/styles/index.scss 2.86 kB {0} [built]
factory:13ms building:8255ms = 8268ms
+ 1 hidden module
npm ERR! Linux 2.6.32-696.23.1.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
npm ERR! node v6.14.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! cb-react-redux@0.1.0 build: `webpack --config webpack.production.config.js --progress --profile --colors`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the cb-react-redux@0.1.0 build script 'webpack --config webpack.production.config.js --progress --profile --colors'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the cb-react-redux package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --config webpack.production.config.js --progress --profile --colors
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs cb-react-redux
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls cb-react-redux
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/psmet/piettest/npm-debug.log
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli
'C:\\Users\\psmet\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-
cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@6.1.0
3 info using node@v8.9.4
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle cb-react-redux@0.1.0~prebuild: cb-react-redux@0.1.0
6 info lifecycle cb-react-redux@0.1.0~build: cb-react-redux@0.1.0
7 verbose lifecycle cb-react-redux@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle cb-react-redux@0.1.0~build: PATH:
C:\Users\psmet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-
lifecycle\node-gyp-bin;C:\Users\psmet\Documents\GUI\trackingcodes\node_modules\.bin;c:\oracle\product\11.2.0\client_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\SysWow64;C:\Users\psmet\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Perforce;C:\Program Files\nodejs\;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Users\psmet\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\psmet\AppData\Local\Programs\Python\Python36\;C:\Users\psmet\AppData\Roaming\npm
9 verbose lifecycle cb-react-redux@0.1.0~build: CWD: C:\Users\psmet\Documents\GUI\trackingcodes
10 silly lifecycle cb-react-redux@0.1.0~build: Args: [ '/d /s /c',
10 silly lifecycle 'webpack --config webpack.production.config.js --progress --profile --colors' ]
11 silly lifecycle cb-react-redux@0.1.0~build: Returned: code: 2 signal: null
12 info lifecycle cb-react-redux@0.1.0~build: Failed to exec build script
13 verbose stack Error: cb-react-redux@0.1.0 build: `webpack --config webpack.production.config.js --progress --profile --colors`
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (C:\Users\psmet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\psmet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid cb-react-redux@0.1.0
15 verbose cwd C:\Users\psmet\Documents\GUI\trackingcodes
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\psmet\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.9.4
19 verbose npm v6.1.0
20 error code ELIFECYCLE
21 error errno 2
22 error cb-react-redux@0.1.0 build: `webpack --config webpack.production.config.js --progress --profile --colors`
var webpack = require('webpack');
var path = require('path');
var loaders = require('./webpack.loaders');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var WebpackCleanupPlugin = require('webpack-cleanup-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
loaders.push({
test: /\.scss$/,
loader: ExtractTextPlugin.extract({fallback: 'style-loader', use : 'css-loader?sourceMap&localIdentName=[local]___[hash:base64:5]!sass-loader?outputStyle=expanded'}),
exclude: ['node_modules']
});
module.exports = {
entry: [
'./app/src/index.jsx',
'./app/styles/index.scss'
],
output: {
publicPath: './',
path: path.join(__dirname, 'public'),
filename: 'bundle2.js'
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
loaders
},
plugins: [
new WebpackCleanupPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
drop_console: true,
drop_debugger: true
}
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new ExtractTextPlugin({
filename: 'style.css',
allChunks: true
}),
]
};
{
"name": "cb-react-redux",
"version": "0.1.0",
"description": "React Webpack Babel Starter Kit",
"main": "''",
"scripts": {
"build": "webpack --config webpack.production.config.js --progress --profile --colors",
"start": "webpack-dev-server --progress --profile --colors",
"lint": "eslint --ext js --ext jsx app || exit 0",
"prod": "node server.js",
"dev": " webpack-dashboard -- webpack-dev-server",
"test": "export NODE_ENV=test && jest"
},
"repository": {
"type": "git",
"url": "https://github.com/alicoding/react-webpack-babel"
},
"author": "Rick Ekins",
"license": "MIT",
"homepage": "https://github.com/alicoding/react-webpack-babel#readme",
"dependencies": {
"axios": "^0.18.0",
"body-parser": "^1.18.2",
"ejs": "^2.5.7",
"express": "^4.16.2",
"http": "0.0.0",
"material-ui": "^0.19.4",
"mysql": "^2.15.0",
"node-sass": "^4.7.2",
"normalize.css": "^7.0.0",
"npm": "^6.1.0",
"query-string": "^6.1.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-ga": "^2.4.1",
"reactstrap": "^5.0.0-alpha.4",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"sass-loader": "^6.0.6",
"serve-favicon": "^2.4.5",
"serve-static": "^1.13.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^21.2.0",
"babel-loader": "^7.1.2",
"babel-plugin-module-resolver": "^3.0.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-runtime": "^6.26.0",
"css-loader": "^0.28.10",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"eslint": "^4.11.0",
"eslint-plugin-jest": "^21.3.2",
"eslint-plugin-react": "^7.5.1",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"html-webpack-plugin": "^2.30.1",
"jest": "^21.2.1",
"loglevel": "^1.6.0",
"postcss-loader": "^2.0.8",
"react-hot-loader": "^3.1.3",
"react-router-dom": "^4.2.2",
"react-router-redux": "^4.0.8",
"react-test-renderer": "*",
"style-loader": "^0.19.0",
"url-loader": "^0.6.2",
"webpack": "^3.8.1",
"webpack-cleanup-plugin": "^0.5.1",
"webpack-dashboard": "^1.0.2",
"webpack-dev-server": "^2.9.4"
},
"jest": {
"verbose": true,
"bail": true,
"collectCoverage": true,
"coverageDirectory": "coverage",
"moduleNameMapper": {
"\\.(jpe?g|png|gif|eot|otf|webp|svg|ttf|woff2?|mp[34]|webm|wav|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less|s[ac]ss|styl)$": "<rootDir>/__mocks__/styleMock.js"
},
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
]
}
}
"use strict";
var webpack = require('webpack');
var path = require('path');
var loaders = require('./webpack.loaders');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var DashboardPlugin = require('webpack-dashboard/plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const HOST = process.env.HOST || "127.0.0.1";
const PORT = process.env.PORT || "8888";
loaders.push({
test: /\.scss$/,
loaders: ['style-loader', 'css-loader?importLoaders=1', 'sass-loader'],
exclude: ['node_modules']
});
module.exports = {
entry: [
'react-hot-loader/patch',
'./app/src/index.jsx', // your app's entry point
],
devtool: process.env.WEBPACK_DEVTOOL || 'eval-source-map',
output: {
publicPath: '/',
path: path.join(__dirname, 'public'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
loaders
},
devServer: {
contentBase: "./public",
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
// embed the webpack-dev-server runtime into the bundle
inline: true,
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
port: PORT,
host: HOST
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin({
filename: 'style.css',
allChunks: true
}),
new DashboardPlugin(),
new HtmlWebpackPlugin({
template: './app/src/template.html',
files: {
css: ['style.css'],
js: [ "bundle.js"],
}
}),
]
};