下载nodejs的压缩包 网址:https://nodejs.org/en/

下载以tar.xz结尾的包例如:node-v8.9.4-linux-x64.tar.xz

上传包到制定的目录 可以用lrzsz

解压:xz -d

node-v8.9.4-linux-x64.tar.xz

然后在 拆包: tar –xvf node-v8.9.4-linux-x64.tar

配置环境变量在/etc/profile

Vim /etc/profilr  最后加入node的变量

export NODE=/root/node-v8.9.4-linux-x64  #node的安装路径

export PATH=$PATH:$NODE/bin          #node的bin目录

推出声明一下

Source  /etc/profile    #环境变量就设好了

查看是否安装成功:出现版本号就是安装成功了

配置npm的源:

npm set registry https://registry.npm.taobao.org/ # 推荐淘宝npm镜像

安装配置sinopia

npm install -g sinopia

启动sinopia

输入:sinopia  启动了就

配置文件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: /home/{user}/.local/share/sinopia/storage # 库存路径,需要考虑磁盘空间

web: # 自定义web项,即浏览器访问页面

# web interface is disabled by default in 0.x, will be enabled soon in 1.x

# when all its issues will be fixed

# set this to `true` if you want to experiment with web ui now;

# this has a lot of issues, e.g. no auth yet, so use at your own risk

#enable: true

title: Sinopia

# logo: logo.png

# template: custom.hbs

auth:

htpasswd:

file: ./htpasswd # 添加用户(npm adduser)后自动创建,保存用户信息,可以初始化用户

# Maximum amount of users allowed to register, defaults to "+inf".

# You can set this to -1 to disable registration.

#max_users: 1000 # 设置为-1不能npm adduser

# a list of other known repositories we can talk to

uplinks: # 可以配置多个上游地址,后面packages中的proxy指定用哪个

npmjs:

url: https://registry.npm.taobao.org/ # 更改此上游地址

# amount of time to wait for repository to respond

# before giving up and use the local cached copy

#timeout: 30s # 请求上游地址超时时间

# maximum time in which data is considered up to date

# default is 2 minutes, so server won't request the same data from

# uplink if a similar request was made less than 2 minutes ago

#maxage: 2m # 包过期时间

# if two subsequent requests fail, no further requests will be sent to

# this uplink for five minutes

#max_fails: 2 # 容许依赖请求最大失败数

#fail_timeout: 5m # 依赖请求超时时间

packages: # 包的权限管理,$all为所有人,$authenticated为通过验证人

# 分布和安装两种权限,值可以特指某几人

'@*/*': # 跟package.json中的name属性进行匹配

# 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}

listen: 0.0.0.0:4873 # 设置监听地址,0.0.0.0匹配本机地址

# if you use nginx with custom path, use this to override links

#url_prefix: https://dev.company.local/sinopia/

# Configure HTTPS, it is required if you use "https" protocol above.

#https:

#  key: path/to/server.key

#  cert: path/to/server.crt

# you can specify proxy used with all requests in wget-like manner here

# (or set up ENV variables with the same name)

#http_proxy: http://something.local/ # 设置代理服务器

#https_proxy: https://something.local/

#no_proxy: localhost,127.0.0.1

# maximum size of uploaded json document

# increase it if you have "request entity too large" errors

#max_body_size: 1mb # http请求body大小

修改uplinks及listen值,同上,重启sinopia
如果想引用别的配置文件,请通过sinopia -c <配置文件>指定

最后更改npm源地址为私有库地址

$ npm set registry http://{服务器ip}:4873/ # 内网测试可行

用pm2托管sinopia

上面方式启动sinopia只是暂时的,退出命令行就没有了,因此需要一个长期开启sinopia方案,通过pm2托管,可以让sinopia进程永远活着,就算意外挂了也可自动重启。
安装pm2

$ npm install -g pm2

安装完后,使用pm2启动sinopia

$ pm2 start sinopia

Nrm是npm的管理工具:

nrm的安装:

添加私有仓库

nrm add mynpm http://192.168.44.139:4873

使用私有仓库

nrm use mynpm

测试私有仓库

$ mkdir test
$ cd test
$ npm install webpack # 第一次安装比较慢
...
 
$ rm -rf webpack
$ npm install webpack # 第二次安装就比较快了

nodejs和npm的安装的更多相关文章

  1. Nodejs 及 NPM 的安装

    Nodejs 及 NPM 的安装,有两种方式: 方式1.Nodejs 及 NPM  一起安装 https://nodejs.org/en/download/  下载  Windows Installe ...

  2. ubuntu下nodejs和npm的安装及升级

    ubuntu 下 nodejs 和 npm 的安装及升级 参考:https://segmentfault.com/a/1190000007542620 一:ubuntu下安装 node 和 npm命令 ...

  3. windows下的Nodejs及npm的安装、常用命令,Nodejs开发环境配置

    http://www.cnblogs.com/webstorm/p/5744942.html ***************************************** 第一步:下载Nodej ...

  4. Ubuntu学习总结-07 Nodejs和npm的安装

    一 安装NodeJS 1 下载nodejs源码 从以下网址下载最新的Nodejs源码 https://nodejs.org/en/download/ 2 安装依赖的 python,gcc,g++ 函数 ...

  5. ubuntu Nodejs和npm的安装

     cnpm install -g XXX errors :  npm i --registry=https://registry.npm.taobao.org     标签: nodejsnpm 20 ...

  6. 2-1 nodejs和npm的安装和环境搭建

    1.安装node.js (最新已经集成npm)  https://nodejs.org/en/ 2.升级npm $ npm install -g npm $ cnpm install -g cnpm ...

  7. nodejs以及npm的安装

    参考资料:http://xiaoyaojones.blog.163.com/blog/static/28370125201351501113581/ 上面的仁兄说的比较清楚,基本解决了安装中遇到的问题 ...

  8. 安装 nodejs,npm,pm2

    一:需要安装组件: nodejs,npm,pm2 安装epel 源: rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel ...

  9. NodeJS、npm安装步骤和配置(windows版本)

    https://jingyan.baidu.com/article/48b37f8dd141b41a646488bc.html 上面这个链接很详细了,怕它没了自己记一遍.我的简洁一点. 1. 打开no ...

随机推荐

  1. 更改dede网站地图模板样式

    dedecms后台可以生成2个地图,一个是网站地图,html格式的,一个是rss地图,同样默认这2个地图生成之后也会有底部的dedecms版权声明,这个时候我们需要分别更改这2个模板才可以去掉底部的版 ...

  2. 从CUMT校园导航出现的问题看CSS布局设计(一) CSS盒模型

    先说说做的这个校园导航系统值得一提的内容: 1. 二级菜单栏  .iframe内嵌窗口(样式设计.用hover做效果) 2. 高德地图API (自定义底图样式.弹跳点.信息窗体.线路导航) 3. DO ...

  3. ASIHTTPRequest

    ASIHTTPRequest,是一个直接在CFNetwork上做的开源项目,提供了一个比官方更方便更强大的HTTP网络传输的封装.

  4. 使用SQL 提示优化sql

    use index 在查询语句中表名的后面,添加use index来提供希望mysql去参考的索引列表,就可以让mysql不再考虑其他可用的索引 explain select * from renta ...

  5. redis五大类型用法

    Redis五大类型:字符串(String).哈希/散列/字典(Hash).列表(List).集合(Set).有序集合(sorted set)五种Controller:@Resource RedisTe ...

  6. HTML5与css3权威指南(一)

    doctype声明: <!DOCTYPE html> 字符编码: <meta charset="utf-8"> 不允许写结束标记:area,base,br. ...

  7. sed&awk第二版读书笔记

    1. POSIX标准对正则表达式字符和操作符的含义进行了形式化.这种标准定义了两类正则表达式:基本的正则表达式(BRE),grep和sed使用这种正则表达式;扩展的表达式,egrep和awk使用这种正 ...

  8. 【视频编解码·学习笔记】4. H.264的码流封装格式

    一.码流封装格式简单介绍: H.264的语法元素进行编码后,生成的输出数据都封装为NAL Unit进行传递,多个NAL Unit的数据组合在一起形成总的输出码流.对于不同的应用场景,NAL规定了一种通 ...

  9. DELL服务器硬件信息采集SHELL脚本

    DELL服务器硬件信息采集SHELL脚本最近需要做资产列表,要采集DELL服务器的硬件信息,包括如下信息:1.操作系统信息(类型,版本,内核,平台,主机名)2.主板信息(厂商,机型,序列号)3.CPU ...

  10. 如何学习java

    1.打牢基础 千里之行始于足下,只有牢固的基础才能走的更远,现在大公司越来越看中一个人的基础如何,他们看中的是你未来的发展潜力,有足够好的基础素养才能实现更多的可能. 2.多敲多练 说实话,光去看代码 ...