我正在尝试构建一个webpack / react项目,但是我不完全确定这个项目是如何或为什么会出错......
命令行表明我的npm /节点可能已经过时,但我昨天刚刚下载了这些东西,所以我不认为这是问题所在。新的反应,欣赏所有的帮助!
package.json :(错误来自npm run build
,似乎不喜欢--config
)
{
"name": "annandale-bbsb",
"version": "1.0.0",
"description": "annandale baseball/softball website",
"main": "index.js",
"scripts": {
"build": "webpack",
"start": "webpack-dev-server"
},
"author": "Riley",
"license": "ISC",
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.0",
"babel-preset-react": "^6.24.1",
"html-webpack-plugin": "^2.28.0",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.5.0"
}
}
webpack.config.js:
var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin(
{
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports =
{
entry: __dirname + '/app/index.js',
module:
{
loaders:
[{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
},
output:
{
filename: 'transformed.js',
path: __dirname + '/build/'
},
plugins: [HTMLWebpackPluginConfig]
};
这会生成这个npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@3.10.10
3 info using node@v6.11.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle annandale-bbsb@1.0.0~prebuild: annandale-bbsb@1.0.0
6 silly lifecycle annandale-bbsb@1.0.0~prebuild: no script for prebuild, continuing
7 info lifecycle annandale-bbsb@1.0.0~build: annandale-bbsb@1.0.0
8 verbose lifecycle annandale-bbsb@1.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle annandale-bbsb@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/Riley/annandale-bbsb/node_modules/.bin:/Users/Riley/Library/Enthought/Canopy_64bit/User/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle annandale-bbsb@1.0.0~build: CWD: /Users/Riley/annandale-bbsb
11 silly lifecycle annandale-bbsb@1.0.0~build: Args: [ '-c', 'webpack' ]
12 silly lifecycle annandale-bbsb@1.0.0~build: Returned: code: 2 signal: null
13 info lifecycle annandale-bbsb@1.0.0~build: Failed to exec build script
14 verbose stack Error: annandale-bbsb@1.0.0 build: `webpack —-config webpack.config.js`
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:891:16)
14 verbose stack at Process.ChildProcess._handle.onexit(internal/child_process.js:226:5)
15 verbose pkgid annandale-bbsb@1.0.0
16 verbose cwd /Users/Riley/annandale-bbsb
17 error Darwin 15.6.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
19 error node v6.11.0
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error annandale-bbsb@1.0.0 build: `webpack —-config webpack.config.js`
22 error Exit status 2
23 error Failed at the annandale-bbsb@1.0.0 build script 'webpack —-config webpack.config.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the annandale-bbsb package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack —-config webpack.config.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs annandale-bbsb
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls annandale-bbsb
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]