problem description
use vue-cli3 to create a component that wants to be encapsulated as a third-party library and uploaded to npm for use by other projects, but vue-cli-service build-- target lib-- name lib1. / src/lib1.vue
the packaged library cannot be used normally. Error:
warning in ./src/App.vue?vue&type=script&lang=js&
"export "default" (imported as "lib1") was not found in "lib1/dist/lib1.umd.js"
vue.runtime.esm.js?2b0e:601 [Vue warn]: Unknown custom element: <lib1> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
related codes
lib1-demo project source code
to easily install the component library from the local source directory: npm install-- save.. / lib1
package.json
{
"dependencies": {
"lib1": "file:../lib1",
"vue": "^2.5.17"
}
}
src/App.vue
<template>
<div id="app">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<lib1></lib1>
</div>
</template>
<script>
import HelloWorld from "./components/HelloWorld.vue"
import lib1 from "lib1/dist/lib1.umd.js"
// import lib1 from "lib1/src/lib1.vue" //
console.log(lib1) // undefined
export default {
name: "app",
components: {
HelloWorld,
lib1
}
}
</script>
what result do you expect? What is the error message actually seen?
Command line warning message when lib1-demo project npm run serve
is started:
warning in ./src/App.vue?vue&type=script&lang=js&
"export "default" (imported as "lib1") was not found in "lib1/dist/lib1.umd.js"
browser console output:
[HMR] Waiting for update signal from WDS...
undefined
vue.runtime.esm.js?2b0e:601 [Vue warn]: Unknown custom element: <lib1> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> <App> at src/App.vue
<Root>