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

npm 发布名称作用域的包 #57

Open
huangshuwei opened this issue Aug 3, 2021 · 0 comments
Open

npm 发布名称作用域的包 #57

huangshuwei opened this issue Aug 3, 2021 · 0 comments

Comments

@huangshuwei
Copy link
Owner

前言

有时我们需要将一类包发布到统一的名称作用域下,典型的如 @vue/cli-plugin-vuex@vue/cli-plugin-router,它们的名称作用域为 "vue"。接下来会介绍如何利用 npm 创建名称作用域。

创建组织

按照npm官网的 创建组织步骤 即可。比如我们创建的组织名称为“our-patches”,创建成功后可以通过 https://www.npmjs.com/org/our-patches 查看当前组织下发布的包。

发布名称作用域包

创建项目时,可以通过命令 npm init --scope=organizationName 初始化,按照提示完成即可。如:

npm init --scope=our-patches

组织默认发布为私有的,可以通过下面命令修改为公共包并发布:

npm publish --access=public

安装

我们的“our-patches”作用域名称下有 “postcss-px-to-viewport”包,我们可以通过以下命令安装:

yarn add @our-patches/postcss-px-to-viewport -D

or

npm install @our-patches/postcss-px-to-viewport -D

--完--

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

No branches or pull requests

1 participant