如何往npm上上传自定义的模块?
1,通过 npm init -y 创建package.json这个记录文件。
2,创建属于自己的模块。
3,上传模块到npm上
3.1:首先要有一个npm账号。(要去验证邮箱)
3.2:打开你的终端,目录切换到你需要上传的模块目录下。切换你的电脑源为 npm源 (这里切换的原因是之前一直用的是国内的淘宝镜像源。)
通过: npx npm use npm
3.3:npm adduser (登录账号)
这里下一步还要验证密码和邮箱,注意:这里输密码时在终端里不会显示的。验证成功后底部会出现 logged in as 你的用户名 on https://registry.npmjs.org/
3.4 npm publish
上传成功最下面会出现 +你的模块名(例如: +shelter_cookie)