-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Cannot assign to read only property 'exports' of object '#<Object>'" when importing library #2675
Comments
Getting this issue as well. |
Update: The problem seems to be related to Update 2: The error is not present with Update 3: The error is definitely in |
I found the missing line that generates the problem: packages/@vue/cli-service/lib/config/base.js:40:
https://webpack.js.org/configuration/resolve/#resolve-symlinks Solution/WorkaroundAdding this to the webpack config in
I dont know why it doesnt break when removing Here's the commit that introduced this change: c9cc225 UpdateIt fails with babel because when not using the symlink, babel doesnt exclude this library because the path that it receives isnt on node_modules |
I think this is the expected behavior. |
I just ran into this issue as well and posted a comment about it here: webpack/webpack#4039 (comment) Workaround: Instead of fiddling with the Using the example from @mrodal's screenshot, move the library under development from Then just link the library as normal and vue-cli/Webpack should correctly exclude that project (and any others under that directory) from transpilation. |
I'm having the exact same issue with the vue-cli. I'm using: For my build script. My index looks like so: import Moetje from './Moetje.vue'
function install(Vue, options) {
Vue.component(options.name || 'Moetje', Moetje)
}
export { Moetje }
export default install And the dist folder looks like this:
The exact error is: Vue cli version = |
One thing that worked for me was telling babel to ignore my commonjs files, as they don't need to be transpiled. babel.config.js module.exports = {
presets: [
'@vue/app',
],
ignore: [
'src/entities/*'
]
} App.vue // commonjs import
const User = require('./entities/User');
// es6 module import
import Component from './components/Button.vue'; |
This may also help: When you're using module locally
|
Thanks @theharshin, running |
Version
3.0.4
Reproduction link
https://github.com/mrodal/vue-cli-lib-ts-error
Node and OS info
npm 6.4.1/node 10.11.0/Windows 10
Steps to reproduce
Create project to be a library with vue-cli. Options: just babel
Create entry file exporting the hello world component
Build library with
vue-cli-service build --target lib --name lib index.js
Create host project. Options: just babel
npm install the library project
use an import statement importing the component
What is expected?
Import successfull
What is actually happening?
Cannot assign to read only property 'exports' of object '#<Object>'
I think it may be related to versions of webpack, vue libraries or something like that, because I have another project that I cannot share because its private, and there, the import works as expected.
In that project that works, if I remove node_modules and package-lock.json and install everything again, it stops working and the same error appears.
The new package-lock.json has different versions on the package's
requires
even if the package has the same version in both files...The text was updated successfully, but these errors were encountered: