centos7 npm 私服
时间: 2023-12-12 14:35:25 浏览: 36
以下是在CentOS 7上搭建npm私服的步骤:
1.安装Node.js和npm
```shell
yum install -y nodejs npm
```
2.安装sinopia
```shell
npm install -g sinopia
```
3.创建sinopia的配置文件
```shell
mkdir /opt/sinopia
cd /opt/sinopia
sinopia --adduser
```
4.编辑sinopia的配置文件
```shell
vi /opt/sinopia/config.yaml
```
将以下内容添加到文件末尾:
```yaml
auth:
htpasswd:
file: /opt/sinopia/htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
access: $all
publish: $authenticated
proxy: npmjs
'**':
access: $all
publish: $authenticated
proxy: npmjs
listen:
- 'http://0.0.0.0:4873/'
```
5.创建sinopia的启动脚本
```shell
vi /etc/systemd/system/sinopia.service
```
将以下内容添加到文件中:
```shell
[Unit]
Description=sinopia
[Service]
ExecStart=/usr/bin/sinopia
Restart=always
User=root
Group=root
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
```
6.启动sinopia服务
```shell
systemctl start sinopia
```
现在,您已经成功地在CentOS 7上搭建了npm私服。