跳到主要内容
版本号:6.x

Node API

Verdaccio 可以通过编程调用。 Node API 是在 verdaccio@3.0.0 版本之后引入的。

使用

编程

const startServer = require("verdaccio").default;

let config = {
storage: "./storage",
auth: {
htpasswd: {
file: "./htpasswd"
}
},
uplinks: {
npmjs: {
url: "https://registry.npmjs.org/",
}
},
self_path: "./",
packages: {
"@*/*": {
access: "$all",
publish: "$authenticated",
proxy: "npmjs",
},
"**": {
proxy: "npmjs"
}
},
log: {
type: "stdout",
format: "pretty",
level: "http",
};
};

startServer(
config,
6000,
undefined,
"1.0.0",
"verdaccio",
(webServer, addrs) => {
webServer.listen(
addrs.port || addrs.path,
addrs.host,
() => {
console.log(`verdaccio running on : ${addrs.host}:${addrs.port}`);
}
);
}
);

其他执行

// js
import * as verdaccioServer from 'verdaccio-server';

verdaccioServer.start();
verdaccioServer.stop();
verdaccioServer.list();
verdaccioServer.stopAll();
verdaccioServer.show();
verdaccioServer.cli();
// windows .net2
verdaccioServer.serviceInstall();
verdaccioServer.serviceUninstall();
verdaccioServer.serviceStart();
verdaccioServer.serviceStop();
verdaccioServer.serviceRestart();