Simple Steps to publish a vue component to npm: npm steps of the vue component
1.0 create a project
1.1 initialize a project
Enter npm init, and write whatever you need to fill in
Create the src directory and create alert. vue under the src directory
$ Npm init $ mkdir src $ cd src $ touch alert. vue
Last directory structure
1.2 modify the entry file
Open package. json and modify
1.3 write component content
This component can be written as needed. Let's test it first. I wrote it like this.
<Template> <div class = "alert"> <div> dddddd </div> </template> <style>. alert {color: red ;}</style> <script> export default {name: 'vue-x-alert '} </script>
2.0 register npm
Open the npm official website, register, and remember the registered account and password, npm-url
2.1 log on to npm and release
$ Npm login // login $ npm publish
2.3 open npm and check the components we just released
Then, we need to use this component in the project to install npm and import it.
Update package
Modify package. json
"Version": "1.1.0 ",
And then release it again.