使用最新的webpack,一直提示“Cannot find module 'webpack/lib/RuleSet'”

来源:2-2 webpack配置项目加载各种静态资源及css预处理器

努力奔跑的自己

2018-07-11 16:07

module.js:557

    throw err;

    ^


Error: Cannot find module 'webpack/lib/RuleSet'

    at Function.Module._resolveFilename (module.js:555:15)

    at Function.Module._load (module.js:482:25)

    at Module.require (module.js:604:17)

    at require (internal/module.js:11:18)

    at Object.<anonymous> (D:\qianduan\study\VUE-SSR-TECH\node_modules\_vue-loader@15.2.4@vue-loader\lib\plugin.js:2:17)

    at Module._compile (module.js:660:30)

    at Object.Module._extensions..js (module.js:671:10)

    at Module.load (module.js:573:32)

    at tryModuleLoad (module.js:513:12)

    at Function.Module._load (module.js:505:3)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! vue-ssr-tech@1.0.0 build: `webpack --config webpack.config.js`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the vue-ssr-tech@1.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

webpack.config.js内容


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: [

{

// 以vue-load 处理以vue结尾的文件,确保正确输出js代码

test: /\.vue$/,

loader: 'vue-loader'

},

{

test:/\.css$/,

// style-loader是将外部css文件注入html文件中,最后将html文件中的css 用css-loader进行解析

use: [

'style-loader',

'css-loader'

]

},

{

test: /\.(gif|jpg|jpeg|png|svg)$/,

use:[

{

loader: 'url-loader',

//将图片转化成base64的代码,直接写在js内容里而不用生成新的文件,减少http请求

//还可以指定输出的文件名字,

options: {

limit:1024,

name:'[name]-aaa.[ext]'

}

}

]

}

]

},

plugins: [

new VueLoaderPlugin()

]

}



写回答 关注

2回答

Vue+Webpack打造todo应用

用前端最热门框架Vue+最火打包工具Webpack打造todo应用

84606 学习 · 787 问题

查看课程

相似问题