我正在学习webpack的学习方法,却陷入了webpack的一幕。每当我尝试在CMD上运行npm run build
命令时,都会出现此错误:
npm错误!代码ELIFECYCLE
npm错误!错误2 npm ERR! open-house@1.0.0版本:
webpack --config config/webpack.prod.js
npm错误!退出状态2
npm错误!
npm错误!在open-house@1.0.0构建脚本中失败。
npm错误! npm可能不是问题。可能还有其他>
在网络上搜索了各种解决方案之后,我在这里结束了,希望你们能为我提供帮助。这是 webpack.config.js :
module.exports = function (options) {
return webpackMerge(commonConfig, {
/**
* Developer tool to enhance debugging
*
* See: http://webpack.github.io/docs/configuration.html#devtool
* See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
*/
devtool: 'cheap-module-eval-source-map',
/**
* Options affecting the output of the compilation.
*
* See: http://webpack.github.io/docs/configuration.html#output
*/
output: {
/**
* The output directory as absolute path (required).
*
* See: http://webpack.github.io/docs/configuration.html#output-path
*/
path: helpers.root(pathBuild),
/**
* Specifies the name of each output file on disk.
* IMPORTANT: You must not specify an absolute path here!
*
* See: http://webpack.github.io/docs/configuration.html#output-filename
*/
filename: '[name].bundle.js',
/**
* The filename of the SourceMaps for the JavaScript files.
* They are inside the output.path directory.
*
* See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
*/
sourceMapFilename: '[name].map',
/** The filename of non-entry chunks as relative path
* inside the output.path directory.
*
* See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
*/
chunkFilename: '[id].chunk.js'
},
plugins: [
/**
* Plugin: DefinePlugin
* Description: Define free variables.
* Useful for having development builds with debug logging or adding global constants.
*
* Environment helpers
*
* See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
*/
// NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
new DefinePlugin({
'ENV': JSON.stringify(METADATA.ENV),
'HMR': METADATA.HMR,
'process.env': {
'ENV': JSON.stringify(METADATA.ENV),
'NODE_ENV': JSON.stringify(METADATA.ENV),
'HMR': METADATA.HMR,
}
}),
/**
* Plugin: NamedModulesPlugin (experimental)
* Description: Uses file names as module name.
*
* See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb
*/
// new NamedModulesPlugin(),
/**
* Plugin LoaderOptionsPlugin (experimental)
*
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
debug: true,
options: {
context: helpers.root('src'),
output: {
path: helpers.root(pathBuild)
},
/**
* Static analysis linter for TypeScript advanced options configuration
* Description: An extensible linter for the TypeScript language.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
tslint: {
emitErrors: false,
failOnHint: false,
resourcePath: 'src'
}
}
})
],
/**
* Webpack Development Server configuration
* Description: The webpack-dev-server is a little node.js Express server.
* The server emits information about the compilation state to the client,
* which reacts to those events.
*
* See: https://webpack.github.io/docs/webpack-dev-server.html
*/
// devServer: {
// port: METADATA.port,
// host: METADATA.host,
// historyApiFallback: true,
// watchOptions: {
// aggregateTimeout: 300,
// poll: 1000
// },
// outputPath: helpers.root(pathBuild)
// },
/*
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: true,
crypto: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
});};
和文件 package.json :
{
"version": "1.0.0",
"name": "",
"private": true,
"scripts": {
"start": "webpack-dev-server --inline --progress",
"test": "karma start",
"protractor": "protractor",
"e2e:live": "npm run e2e -- --elementExplorer",
"e2e": "npm run protractor",
"pree2e": "npm run webdriver:update -- --standalone",
"webdriver-manager": "webdriver-manager",
"webdriver:start": "npm run webdriver-manager start",
"webdriver:update": "npm run webdriver-manager update",
"tslint": "tslint",
"build": "webpack --config config/webpack.prod.js",
"build:dev": "webpack --config config/webpack.dev.js",
"build:prod": "webpack --config config/webpack.prod.js",
"webpack": "webpack",
"rimraf": "rimraf",
"rebuild-sass": "npm rebuild node-sass"
},
"dependencies": {
"@angular/animations": "^4.0.2",
"@angular/common": "^4.0.2",
"@angular/compiler": "^4.0.2",
"@angular/compiler-cli": "^4.0.2",
"@angular/core": "^4.0.2",
"@angular/forms": "^4.0.2",
"@angular/http": "^4.0.2",
"@angular/platform-browser": "^4.0.2",
"@angular/platform-browser-dynamic": "^4.0.2",
"@angular/platform-server": "^4.0.2",
"@angular/router": "^4.0.2",
"@angularclass/conventions-loader": "^1.0.2",
"@angularclass/hmr": "~1.2.2",
"@angularclass/hmr-loader": "~3.0.2",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "0.0.3",
"amcharts3": "github:amcharts/amcharts3",
"ammap3": "github:amcharts/ammap3",
"angulartics2": "^2.0.0",
"animate.css": "3.5.2",
"assets-webpack-plugin": "3.5.1",
"bootstrap": "4.0.0-alpha.4",
"bootstrap-loader": "2.0.0-beta.19",
"chart.js": "1.1.1",
"chartist": "0.10.1",
"ckeditor": "4.6.2",
"core-js": "2.4.1",
"extract-text-webpack-plugin": "2.1.0",
"font-awesome": "4.7.0",
"font-awesome-animation": "0.1.0",
"font-awesome-sass-loader": "2.0.1",
"fullcalendar": "3.6.2",
"google-maps": "3.2.1",
"http-server": "0.9.0",
"ie-shim": "0.1.0",
"ionicons": "2.0.1",
"jquery": "3.2.1",
"jquery-slimscroll": "1.3.8",
"jquery-touch-events": "1.0.7",
"leaflet": "0.7.7",
"leaflet-map": "0.2.1",
"lodash": "4.17.4",
"moment": "^2.13.0",
"ng2-ckeditor": "1.1.6",
"ng2-responsive": "^0.6.9",
"ng2-slim-loading-bar": "^2.0.4",
"ng2-toasty": "^4.0.0",
"ng2-validation": "^4.2.0",
"ngx-pipes": "^1.5.7",
"ngx-uploader": "2.2.5",
"normalize.css": "6.0.0",
"postcss-load-config": "1.0.0",
"postcss-loader": "1.3.3",
"primeng": "5.2.2",
"rxjs": "^5.5.3",
"tether": "1.4.0",
"typescript": "~2.3.3",
"zone.js": "0.8.5",
"webpack-sources": "^1.0.1"
},
"devDependencies": {
"angular2-router-loader": "^0.3.4",
"angular2-template-loader": "^0.6.0",
"@types/fullcalendar": "2.7.40",
"@types/hammerjs": "2.0.34",
"@types/jasmine": "2.5.47",
"@types/jquery": "2.0.41",
"@types/jquery.slimscroll": "1.3.30",
"@types/lodash": "4.14.61",
"@types/node": "7.0.12",
"@types/source-map": "0.5.0",
"@types/uglify-js": "2.6.28",
"@types/webpack": "2.2.14",
"ts-helpers": "1.1.2",
"ts-node": "3.0.2",
"tslib": "1.6.0",
"tslint": "4.5.1",
"typedoc": "0.5.10",
"gh-pages": "0.12.0",
"parse5": "^2.2.2",
"rimraf": "2.6.1",
"codelyzer": "2.1.1",
"awesome-typescript-loader": "3.1.2",
"url-loader": "0.5.8",
"style-loader": "0.16.1",
"raw-loader": "0.5.1",
"source-map-loader": "0.2.1",
"string-replace-loader": "1.2.0",
"imports-loader": "0.7.1",
"json-loader": "0.5.4",
"css-loader": "0.28.0",
"exports-loader": "0.6.4",
"expose-loader": "0.7.3",
"file-loader": "0.11.1",
"to-string-loader": "1.1.5",
"sass-loader": "6.0.3",
"resolve-url-loader": "2.0.2",
"html-loader": "^0.4.4",
"postcss-loader": "1.3.3",
"istanbul-instrumenter-loader": "2.0.0",
"node-sass": "4.7.2",
"html-webpack-plugin": "^3.2.0",
"copy-webpack-plugin": "4.0.1",
"v8-lazy-parse-webpack-plugin": "^0.3.0",
"webpack": "2.3.3",
"webpack-dev-middleware": "1.10.1",
"webpack-dev-server": "2.4.2",
"webpack-dll-bundles-plugin": "1.0.0-beta.5",
"webpack-merge": "4.1.0",
"webpack-externals-plugin": "^1.0.0",
"webpack-md5-hash": "^0.0.5",
"compression-webpack-plugin": "^1.1.10",
"script-ext-html-webpack-plugin": "1.7.1",
"extract-text-webpack-plugin": "2.1.0",
"es6-promise": "4.1.0",
"es6-shim": "0.35.3",
"es7-reflect-metadata": "1.6.0",
"ng2-validation": "^4.2.0"
}
}
感谢您的帮助!