windows 环境部署私有 npm 源
sinopia 是一个零配置带缓存功能的 npm 包管理工具。sinopia 有以下几个优势值得关注:
服务器部署安装> npm install -g sinopia 启动> sinopia warn --- config file - C:UsersjasonAppDataRoamingsinopiaconfig.yaml warn --- http address - http://localhost:4873/ 打开 http://localhost:4873/ 如果能正常显示,说明安装成功。
?
?
sinopia 启动时默认会创建 > sinopia -c D:sinopiaconfig.yaml 现在我们就可以在指定目录下运行了,以后上传的 npm 包也会放在这个目录中。 配置config.yaml 是用来配置访问权限,代理,文件存储路径等所有配置信息的: # # This is the default config file. It allows all users to do anything,# so don‘t use it on production systems. # # Look here for more config file examples: # https://github.com/rlidwka/sinopia/tree/master/conf # # path to a directory with all packages storage: ./storage //npm包存放的路径 auth: htpasswd: file: ./htpasswd //保存用户的账号密码等信息 # Maximum amount of users allowed to register,defaults to "+inf". # You can set this to -1 to disable registration. max_users: -1 //默认为1000,改为-1,禁止注册 # a list of other known repositories we can talk to uplinks: npmjs: url: http://registry.npm.taobao.org/ //默认为npm的官网,由于国情,修改 url 让sinopia使用 淘宝的npm镜像地址 packages: //配置权限管理 ‘@*/*‘: # scoped packages access: $all publish: $authenticated ‘*‘: # allow all users (including non-authenticated users) to read and # publish all packages # # you can specify usernames/groupnames (depending on your auth plugin) # and three keywords: "$all","$anonymous","$authenticated" access: $all # allow all known users to publish packages # (anyone can register by default,remember?) publish: $authenticated # if package is not available locally,proxy requests to ‘npmjs‘ registry proxy: npmjs # log settings logs: - {type: stdout,format: pretty,level: http} #- {type: file,path: sinopia.log,level: info} # you can specify listen address (or simply a port) listen: 0.0.0.0:4873 ////默认没有,只能在本机访问,添加后可以通过外网访问。
客户端使用全局安装 > npm install -g nrm # 安装nrm > nrm add XXXX http://XXXXXX:4873 # 添加私有 npm 镜像地址 > nrm use XXXX # 使用私有镜像地址
注意: 不建议使用私有源安装公网 npm 包,安装公网 npm 包请使用 taobao 源
nrm 其他命令: > nrm --help # 查看nrm命令帮助 > nrm list # 列出可用的 npm 镜像地址 > nrm use taobao # 使用`淘宝npm`镜像地址
常用 npm 命令注册发布者 > npm adduser # 按提示输入用户名,密码,邮箱即可
登陆 npm 源 > npm login # 按提示输入用户名,密码,邮箱即可
发布 npm 包 > cd D:projectsyourproject # 进入项目目录 > npm publish # 执行发布命令
删除 npm 包 > npm unpublish <package>@<version> # 例: npm unpublish [email?protected]
删除发布者 > npm <owner> rm <user> <package> # 例: npm admin rm test flagwind
查看模块所有者 > npm <owner> ls <package> # 例: npm admin ls flagwind
安装问题在 Windows 下直接执行这个命令会遇到一些问题: 1、Python 没有安装或版本不对 gyp ERR! stack Error: Can‘t find Python executable "python",you can set the PYTHON env variable.
解决方案: node-gyp 依赖 Python 2.7,安装 Python2.7 并把它添加到环境变量 PATH 中。 > npm config set python C:Python27python.exe
2、MSBuild 版本不对 MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available too ls versions are "4.0"
解决方案: node-gyp 需要用到 Visual C++ Build Tools,百度搜索并安装即可。 3、Windows下不支持 fs-ext 和 crypt3 node-gyp 报编译 fs-ext 和 crypt3 失败的错误,安装 sinopia 时可以忽略,错误信息如下: fs-ext.cc(195): error C3861: ‘fcntl‘: identifier not found [C:UsersclcazaAppDataRoamingnpmnode_modulessinopianode_modules.0.[email?protected]buildfs-ext.vcxproj] crypt3.cc(5): fatal error C1083: Cannot open include file: ‘unistd.h‘: No such file or directory [C:UsersclcazaAppDataRoamingnpmnode_modulessinopianode_modules.0.[email?protected]buildcrypt3.vcxproj]
解决方案: sinopia 依赖于 来源:https://www.jianshu.com/p/c2a569be60a9 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- active-directory – 我是否仍然拥有物理DC,即使是在Server
- Windows系统CPU内存网络性能统计第四篇 CPU 多核CPU各核使用
- Windows上的boot2docker – 无法访问暴露的端口
- windows – goapp serve:无法找到dev_appserver.py
- windows-server-2012 – Windows 2012 Autounattend仍在询问
- 适合Windows的命令行shell
- windows-phone-7 – 是否可以仅为一个Pivot项目显示应用程序
- .net – Windows XP上的DateTime.ToLocalTime
- PTA-1017——Queueing at Bank(部分正确,查错半天没找到错
- 如何在Windows上安装igraph for python