关于vue-server-renderer/server-plugin
来源:1-7 (如果您初学,建议您先跟着课程版本走,项目完成后再升级)补充vue-loader15.6.2升级

慕雪4779524
2021-04-16
可能是webpack升级到5.0了报的这个错, 一个是反馈没有指定入口文件,另一个是 没有指定libraryTarget为commonjs2, 不知道该怎么解决,后面的工作无法继续下午了! 这两个值都有设置的不知道为什么会报这个错!
3回答
-
你好,你需要手动去更改文件\node_modules\vue-server-renderer\server-plugin.js
标粗的那几行是新加的,减号的那几行注释掉
- if (compiler.options.output && compiler.options.output.libraryTarget !== 'commonjs2') {+ if (compiler.options.output && compiler.options.output.library.type !== 'commonjs2') {
- var entryAssets = entryInfo.assets.filter(isJS);
+ var entryAssets = entryInfo.assets.filter(file => isJS(file.name));if (entryAssets.length > 1) {
throw new Error(
"Server-side bundle should have one single entry file. " +
"Avoid using CommonsChunkPlugin in the server config."
)
}
var entry = entryAssets[0];- if (!entry || typeof entry !== 'string') {
+ if (!entry || typeof entry.name !== 'string') {
throw new Error(
("Entry \"" + entryName + "\" not found. Did you specify the correct entry option?")
)
}
var bundle = {+ entry: entry.name,
files: {},
maps: {}
};012021-04-22 -
Jokcy
2021-04-20
应该是这个server plugin不兼容webpack5,你试试安装webpack4
00 -
Junble
2021-04-20
后期可能还会遇到报错:TypeError: Cannot read property 'file' of undefined
需要更改文件/node_modules/vue-server-renderer/build.dev.js- var needed = [initial[0]].concat(async, initial.slice(1));
+ var needed = (initial.length ? [initial[0]] : []).concat(async, initial.slice(1));
012021-04-20
相似问题