【发布时间】:2017-11-09 13:31:50
【问题描述】:
我有一个包含package.json 的存储库,其中包含范围依赖项。我还有一个.npmignore 文件,旨在将dist/ 中的所有文件和子目录列入白名单。问题是在运行 npm install @private/a 另一个存储库时包含所有作用域依赖项。这包括私有 npm 包和公共包,例如 @uirouter。
package.json:
{
"name": "@private/a",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@bitbucket.org/private/a.git"
},
"author": "",
"license": "ISC",
"homepage": "https://bitbucket.org/private/a#readme",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-angular-embed-templates": "^2.3.0",
"gulp-concat": "^2.6.1",
"gulp-jshint": "^2.0.4",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.0.0",
"gulp-uglify": "^2.0.0",
"jshint": "^2.9.4"
},
"dependencies": {
"@private/b": "^1.0.0",
"@private/c": "^1.0.0"
}
}
.npmignore
**
!dist/**
尽管有这两个文件,但当我在另一个存储库中运行 npm install @private/a --save 时,它正在安装依赖项及其所有作用域依赖项:
/node_modules/@private/a/dist/index.js
/node_modules/dist/css/styles.css
/node_modules/@private/a/node_modules/@private/b
/node_modules/@private/a/node_modules/@private/c
package.json
应该是这样的:
/node_modules/@private/a/dist/index.js
/node_modules/dist/css/styles.css
package.json
我怎样才能做到这一点?我尝试了.npmignore 的不同变体,但没有任何运气。
【问题讨论】:
-
运行包
@private/a需要@private/b和@private/c吗? -
或者它们仅在
@private/a开发和构建期间需要,是吗?