【问题标题】:Subpackage is not included in my npm module我的 npm 模块中不包含子包
【发布时间】:2018-03-23 21:10:04
【问题描述】:

我有一个名为“ldap-pool”的 npm 模块。这个包依赖于'ldapjs'和'@types/ldapjs',但由于某种原因,当我将'ldap-pool'安装到另一个项目中时,'@types/ldapjs'包没有被安装。 以上是问题。

'ldap-pool' 的 package.json 文件如下:

{
  "name": "ldap-pool",
  "version": "0.0.1011",
  "description": "LDAP client connection pool",
  "main": "index.js",
  "types": "index.d.ts",
  "typings": "index.d.ts",
  "scripts": {
    "test": "./@test.sh"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ORESoftware/ldap-pool.git"
  },
  "keywords": [
    "ldap",
    "pool",
    "client",
    "connection",
    "ldapjs"
  ],
  "author": "Olegzandr VD",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/ORESoftware/ldap-pool/issues"
  },
  "homepage": "https://github.com/ORESoftware/ldap-pool#readme",
  "dependencies": {
    "chalk": "^1.1.3",
    "ldapjs": "^1.0.1"
  },
  "devDependencies": {
    "@types/chalk": "^0.4.31",
    "@types/ldapjs": "^1.0.0",
    "@types/node": "^7.0.31"
  }
}

当我在另一个项目中安装 ldap-pool 时,我看到:

如果我将鼠标悬停在红色波浪上,我会看到:

有谁知道为什么我运行时没有包含ldapjs 分型

npm install

?

【问题讨论】:

  • 我不认为.npmignore.gitignore 会影响这一点,所以我没有提及它们

标签: node.js typescript npm typescript2.0 ldapjs


【解决方案1】:

需要将类型文件移动到 ldap-pool package.json 的依赖项部分。将模块用作依赖项时,不会下载模块的任何 devDependencies。

...
"dependencies": {
  "chalk": "^1.1.3",
  "ldapjs": "^1.0.1",
  "@types/chalk": "^0.4.31",
  "@types/ldapjs": "^1.0.0",
  "@types/node": "^7.0.31"
}
...

【讨论】:

  • 我发誓过去是包含 devDependencies 的情况,但也许随着新的 NPM 版本不再是这种情况,将对此进行测试。谢谢。
猜你喜欢
  • 1970-01-01
  • 2019-09-11
  • 2016-11-06
  • 1970-01-01
  • 2020-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多