网站建设属于什么经营类型,自己做炉石卡牌的网站,关键词怎么选择技巧,小程序登录不了为什么要搭建npm私有库#xff1f; 为了方便下载时#xff0c;公共包走npmjs,私有包走内部服务器。npm包下载的速度较慢#xff0c;搭建npm私有库之后#xff0c;会先操作私有库中是否有缓存#xff0c;有缓存直接走缓存#xff0c;而不用重新再去请求一遍网络。哪种方式…为什么要搭建npm私有库 为了方便下载时公共包走npmjs,私有包走内部服务器。npm包下载的速度较慢搭建npm私有库之后会先操作私有库中是否有缓存有缓存直接走缓存而不用重新再去请求一遍网络。哪种方式适合你呢 npm私有库的搭建有很多种具体哪种方式适合我选择的方案是比较简单的“使用verdaccio搭建npm私有库”。 先试着在本地搭建一个吧 准备工作 我们需要使用npm命令去安装verdaccio,所以我们必须要有node环境node环境又依赖于python。因此在搭建npm私有库的准备工作就是去搭建node环境。 检测是否有node环境 chenwentaodeiMac:ceair_wallet chenwentao$ node -v
bash: node: command not found
复制代码 下载node 安装node 检验是否安装成功 chenwentaodeiMac:ceair_wallet chenwentao$ node -v
v10.15.1
复制代码 安装启动verdaccio 安装verdaccio 安装速度缓慢的话可以使用淘宝镜像,install时遇到permission denied记得前面加sudo chenwentaodeiMac:ceair_wallet chenwentao$ sudo cnpm install -g verdaccio
复制代码 启动verdaccio 启动成功后打开http://localhost:4873/看到界面就表示成功了 chenwentaodeiMac:ceair_wallet chenwentao$ verdacciowarn --- config file - /Users/chenwentao/.config/verdaccio/config.yaml //配置文件warn --- Plugin successfully loaded: htpasswd //保存用户账户、密码等信息warn --- Plugin successfully loaded: auditwarn --- http address - http://localhost:4873/ - verdaccio/3.11.4 //地址
复制代码 配置文件 默认的配置文件允许所有的用户拥有任何的权限。 #
# This is the default config file. It allows all users to do anything,
# so dont use it on production systems.
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
## path to a directory with all packages 存储npm包的路径
storage: ./storage
# path to a directory with plugins to include
plugins: ./pluginsweb:# WebUI is enabled as default, if you want disable it, just uncomment this line # web页面的配置 即上面的http://localhost:4873/ 默认为可访问。title就是标题可以修改#enable: falsetitle: Verdaccioauth:
# 保存用户账户、密码等信息文件可以将max_users设置为-1禁止用户添加从而通过修改htpasswd来添加用户htpasswd:file: ./htpasswd# Maximum amount of users allowed to register, defaults to inf.# You can set this to -1 to disable registration.#max_users: 1000# a list of other known repositories we can talk to
# 访问公共库的路径可以修改成淘宝镜像 https://registry.npm.taobao.org
uplinks:npmjs:url: https://registry.npmjs.org/packages:*/*:# scoped packagesaccess: $allpublish: $authenticatedproxy: npmjs**:# 配置权限# 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, $authenticatedaccess: $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 registryproxy: npmjs# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought.
server:keepAliveTimeout: 60# To use npm audit uncomment the following section
middlewares:audit:enabled: true# log settings
logs:- {type: stdout, format: pretty, level: http}#- {type: file, path: verdaccio.log, level: info}
# 配置之后相同wifi下其他电脑也可以访问了 访问地址为你的ip加上端口4873
listen: 0.0.0.0:4873复制代码 客户端配置 本地的私有仓库已经搭建好了接下来我们需要通过客户端配置registry来使用我们的私有仓库。在浏览器中打开http://10.68.18.154:4873/时会有提示(10.68.18.154是本机的IP地址) Login: npm adduser --registry http://10.68.18.154:4873
复制代码Publish: npm publish --registry http://10.68.18.154:4873
复制代码 在linux服务器上尝试一下 刚才我们在本地构建了一个npm私有库现在我们到Linux服务器上尝试一下吧。首先检测一下有没有安装node和python如果没有安装就进行安装那么我们接下来来安装一下。 安装python 在Linux上安装python需要用命令行去操作。 下载 解压 安装node 下载 解压 接下来和本地一样去创建npm私有库创建完之后让我们永久的运行verdaccio吧。 永久运行verdaccio sudo npm install -g forever
forever start which verdaccio
复制代码 转载于:https://juejin.im/post/5c92dbadf265da611360391e