Skip to content
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

Vue compiler fails when working ( Vue cli 3?) #52

Closed
Tallyb opened this issue Sep 3, 2019 · 2 comments
Closed

Vue compiler fails when working ( Vue cli 3?) #52

Tallyb opened this issue Sep 3, 2019 · 2 comments

Comments

@Tallyb
Copy link
Contributor

Tallyb commented Sep 3, 2019

Installing a component and then importing it raises an error:

on serve - the following errors exist:

'define' is not defined (no-undef) at components/product-list/dist/main.js:1:123:
and more errors...

And this is shown in the browser:

vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <ProductList> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <App> at src/App.vue
       <Root>

STR:

  1. create a new vue cli project with version 3 (npx @vue/cli create new-project). Cd and install.
  2. install this component: https://bit.dev/tallyb/vue-tutorial/product-list
  3. Change the app.vue code to be:
<template>
  <div id="app">
    <ProductList />
  </div>
</template>

<script>
import ProductList from '@bit/tallyb.vue-tutorial.product-list';

export default {
  name: 'app',
  components: {
    ProductList
  }
}
</script>
  1. npm run serve - runs ok.
  2. import the component and run serve again.
@GiladShoham
Copy link
Member

The difference between bit import and npm install is when you use bit import we added the path of the component in the package.json in the form of file: [comp-path].
Then npm create the folder in the node_modules using a symlink.
By default webpack resolve symlink to the real path which breaks babel.
It can be disabled in the webpack.config via the vue.config.js
read more about it here:
https://cli.vuejs.org/guide/troubleshooting.html#symbolic-links-in-node-modules
vuejs-templates/webpack-simple#171 (comment)

@JoshK2 will put a vue.config.js for example that works as expected.

@GiladShoham
Copy link
Member

here is an example config (can be done in other ways as well):

// vue.config.js
module.exports = {
    // options...
    configureWebpack: {
        resolve: {
            symlinks: false // support npm link
        }
    }
}

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

No branches or pull requests

2 participants