Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

vue-cli配置多页,eslint报错 'entry' of 'pageConfig' as it is undefined

vue-cli配置了pages对象

const files = fs.readdirSync('./src/pages')
files.forEach(n => {
  pages[n] = {
    entry: `./src/pages/${n}/main.js`, // page 的入口
    template: './src/public/index.html', // 模板来源
    filename: 'index.html', // 在 dist/index.html 的输出
    favicon: './src/public/favicon.ico',
    title: '首页',
    chunks: ['chunk-vendors', 'chunk-common', n]
  }
})

然后装了@vue/cli-plugin-eslint
import 资源会引起报错

Resolve error: TypeError: Cannot destructure property 'entry' of 'pageConfig' as it is undefined.

at D:\git\frontend\node\_modules\@vue\cli-service\lib\config\app.js:198:11

at Array.forEach (<anonymous>)

at D:\git\frontend\node\_modules\@vue\cli-service\lib\config\app.js:195:13

at D:\git\frontend\node\_modules\@vue\cli-service\lib\Service.js:251:40

at Array.forEach (<anonymous>)

at Service.resolveChainableWebpackConfig (D:\git\frontend\node\_modules\@vue\cli-service\lib\Service.js:251:26)

at Service.resolveWebpackConfig (D:\git\frontend\node\_modules\@vue\cli-service\lib\Service.js:255:48)

at Object.<anonymous> (D:\git\frontend\node\_modules\@vue\cli-service\webpack.config.js:12:26)

at Module.\_compile (internal/modules/cjs/loader.js:880:30)

at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:892:10)eslint(import/no-duplicates)

pageConfig 是什么东西?没有搜索到有关的问题.望大佬解答


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

看了眼代码 这个错误是解构的时候报的 要结构的对象是个undefined 所以你得看看你的配置里的pages是不是写好了 你能把你vue 配置这块代码写出来吗 你现在的代码看不出来 不知道你这个pages最后怎么处理的

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...