Simple Steps to publish a vue component to npm: npm steps of the vue component

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.