Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

@vue/cli 4.x build:prod出现'exports' of object '#<Object>' #3271

Closed
TyCoding opened this issue Jun 19, 2020 · 7 comments
Closed

@vue/cli 4.x build:prod出现'exports' of object '#<Object>' #3271

TyCoding opened this issue Jun 19, 2020 · 7 comments

Comments

@TyCoding
Copy link

本地环境:@vue/cli 4.4.4、node v14.4.0、wepack@4.43.0、MacOS 10.15
使用命名:npm run build:prod 项目,部署在Nginx上,访问控制台出现如下错误:

ncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

项目并未做任何改动,直接clone下build的,请问这是什么原因啊?在dev环境下没有问题

@TyCoding
Copy link
Author

找到了解决办法,在不改动package.json中版本的情况下:
仅在vue.config.js中添加如下代码:

 config.module
      .rule('js')
      .test(/\.js$/)
      .include.add(resolve('src')).add(resolve('test'))
      .end()
      .use('babel-loader')
      .loader('babel-loader')
      .end()

具体原因有知道的大佬可以在下面解答一下

@shskyc
Copy link

shskyc commented Jun 19, 2020

你的解决方法有效,感谢

@moons7
Copy link

moons7 commented Jun 20, 2020

查了下资料,原因可能是最近作者添加了module.exports的语法与import的冲突 (与#3246有关)。。
临时修改babel.confige.js如下可以解决,但具体原因还是让大佬分析

module.exports = { presets: [ '@vue/app' ], sourceType: 'unambiguous' }

@PanJiaChen
Copy link
Owner

vuejs/vue-cli#4797

@moons7 正解

@PanJiaChen
Copy link
Owner

Fixed in ae2aa61

@zboboan
Copy link

zboboan commented Jul 14, 2020

找到了解决办法,在不改动package.json中版本的情况下:
仅在vue.config.js中添加如下代码:

 config.module
      .rule('js')
      .test(/\.js$/)
      .include.add(resolve('src')).add(resolve('test'))
      .end()
      .use('babel-loader')
      .loader('babel-loader')
      .end()

具体原因有知道的大佬可以在下面解答一下

非常感谢

@DWsande
Copy link

DWsande commented Apr 7, 2021

找到了解决办法,在不改动package.json中版本的情况下:
仅在vue.config.js中添加如下代码:

 config.module
      .rule('js')
      .test(/\.js$/)
      .include.add(resolve('src')).add(resolve('test'))
      .end()
      .use('babel-loader')
      .loader('babel-loader')
      .end()

具体原因有知道的大佬可以在下面解答一下

非常感谢

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants