使用npm run build時,出現下面的問題
使用npm run build時,出現下面的問題。檢查代碼,應該是沒有寫錯的。怎么解決呢?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `webpack --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!? ? ?/Users/mymac/.npm/_logs/2018-09-18T07_41_36_761Z-debug.log
我按照教學視頻配置的代碼如下:




2018-09-24
const?path?=?require('path') const?{?VueLoaderPlugin?}?=?require('vue-loader') module.exports?=?{ ????entry:?path.join(__dirname,'src/index.js'), ????output:?{ ????????filename:?"bundle.js", ????????path:?path.join(__dirname,'dist') ????}, ????module:?{ ????????rules:?[ ????????????{ ????????????????test:?/\.vue$/, ????????????????loader:?'vue-loader' ????????????}, ????????????{ ????????????????test:?/\.css$/, ????????????????use:?['style-loader',?'css-loader'] ????????????}, ????????????{ ????????????????test:?/\.(gif|jpg|jpeg|png|svg)$/, ????????????????use:?[ ????????????????????{ ????????????????????????loader:?'url-loader', ????????????????????????options:?{ ????????????????????????????limit:?1024, ????????????????????????????name:?'[name].[ext]' ????????????????????????} ????????????????????} ????????????????] ????????????} ????????] ????}, ????plugins:?[ ????????new?VueLoaderPlugin() ????] }2018-09-24
這個可能是你有在webpack.config.js中加入plugins(我多裝了style-loader url-loader file-loader)
const?path?=?require('path') module.exports?=?{ ????entry:?path.join(__dirname,'src/index.js'), ????output:?{ ????????filename:?"bundle.js", ????????path:?path.join(__dirname,'dist') ????}, ????module:?{ ????????rules:?[ ????????????{ ????????????????test:?/\.vue$/, ????????????????loader:?'vue-loader' ????????????}, ????????????{ ????????????????test:?/\.css$/, ????????????????use:?['style-loader',?'css-loader'] ????????????}, ????????????{ ????????????????test:?/\.(gif|jpg|jpeg|png|svg)$/, ????????????????use:?[ ????????????????????{ ????????????????????????loader:?'url-loader', ????????????????????????options:?{ ????????????????????????????limit:?1024, ????????????????????????????name:?'[name].[ext]' ????????????????????????} ????????????????????} ????????????????] ????????????} ????????] ????}, ???? }2018-09-18
這個是新版本的webpack有更改過的緣故,只要把<style></style>中間的樣式注釋掉就不會報錯,應該是少了一個關于style的插件,但具體是什么我暫時也不知道