npm从gitlab安装私有节点库

时间:2019-04-26 07:18:43

标签: node.js npm gitlab npm-install verdaccio

我在gitlab中创建了一个库(国家/地区),我想将其安装在另一个项目中。该库使用我的另一个库(数据加载器)。当我在项目中运行npm i时,它会安装国家/地区,然后使用dataloader在国家/地区内创建另一个node_modules。我想要主node_modules中的数据加载器库。我无法理解为什么dataloader程序包未包含在项目node_modules中

Example Project
|
+--node_modules
  |
  +--country
     |
     +--node_modules
       |
       +--dataLoader

但是当我尝试使用npm时,请根据需要创建git + http://xxxxxxxxx/countries.git#master文件夹结构。

将此数据加载器存储库发布到npm上,并在package.json中使用dataloader版本路径,然后运行npm install然后根据需要创建文件夹结构。

Example Project
|
+--node_modules
  |
  +--country
  +--dataLoader

Country Package.json

{
  "name": "countries",
  "version": "1.0.0",
  "description": "An array of countries contains Iso country code,country name,has postal code(boolean value),zip regex etc",
  "main": "index.js",
  "scripts": {
    "test": "CONFIGURATION='test/testConfig.json' mocha"
  },
  "dependencies": {
    "dataloader": "git+http://xxxxxxxxxx/foundation/reference-data/dataloader.git#master",
    "lodash": "^4.17.11"
  },
  "devDependencies": {
    "chai": "^4.2.0",
    "mocha": "^6.0.2"
  }
}

示例项目package.json

{
  "name": "example",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "env NODE_ENV='debug'  node country.js"
  },
  "repository": {
    "type": "git",
    "url": "https://git.xxxx.com/xxx/xx/example.git"
  },
  "author": "",
  "standard": {
    "env": [
      "mocha"
    ]
  },
  "license": "ISC",
  "dependencies": {
    "countries": "git+http://xxxxx/foundation/reference-data/countries.git#master"
  }
}

我希望当我运行npm时,安装文件夹结构会像下面那样创建,但是我不想在npm上发布我的库,我希望它在gitlab上是私有的

Example Project
|
+--node_modules
  |
  +--country
  +--dataLoader

0 个答案:

没有答案
相关问题