sxy15 / ISSUE

MIT License
1 stars 0 forks source link

npm私服搭建 #1

Closed sxy15 closed 11 months ago

sxy15 commented 12 months ago

node.js 安装

1. cd /usr/local/src
2. sudo wget https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz
3. tar -xvf node-v20.10.0-linux-x64.tar.xz
4. sudo ln -s /usr/local/src/node-v20.10.0-linux-x64/bin/node /usr/bin/node
5. sudo ln -s /usr/local/src/node-v20.10.0-linux-x64/bin/npm /usr/bin/npm
node v20.10.0
npm 10.2.3
sxy15 commented 12 months ago

拉取cnpmjs 仓库

1. git clone https://github.com/cnpm/cnpmjs.org.git
2. cd cnpmjs.org
3. sudo npm install
sxy15 commented 12 months ago

安装mysql-server

sudo apt install mysql-server

安装成功,mysql服务自动启动,可以通过下边命令验证

sudo systemctl status mysql
sxy15 commented 11 months ago

在 cnpmjs.org 目录下执行:

mysql -uroot -p<password> -e 'DROP DATABASE IF EXISTS cnpmjs_test;' &&\
mysql -uroot -p<password> -e 'CREATE DATABASE cnpmjs_test;' &&\
mysql -uroot -p<password> 'cnpmjs_test' < docs/db.sql &&\
mysql -uroot -p<password>'cnpmjs_test' -e 'show tables;'

+-----------------------+ | Tables_in_cnpmjs_test | +-----------------------+ | dist_dir | | dist_file | | download_total | | module | | module_deps | | module_keyword | | module_log | | module_maintainer | | module_star | | module_unpublished | | tag | | total | | user | +-----------------------+

sxy15 commented 11 months ago
vi ./config/index.js

修改 database config配置:

db: 'cnpmjs_test',
username: 'root',
password: 'xxxxxx',
dialect: 'mysql',

启动服务

sudo node dispatch.js 

注释bindingHost一行,对外网开放

sxy15 commented 11 months ago

设置源

nrm add sxy15 http://x.x.x.x:7001   
nrm use sxy15
sxy15 commented 11 months ago

建了一个@cnpm/nnn 的包,然后添加用户进行发布

npm adduser
npm publish

然后就可以看到对应的包了!

  1. 遇到了ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 报错
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxxx';