我有一个包含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"
}
}
Run Code Online (Sandbox Code Playgroud)
.npmignore
**
!dist/**
Run Code Online (Sandbox Code Playgroud)
尽管我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
Run Code Online (Sandbox Code Playgroud)
它应该只是这样:
/node_modules/@private/a/dist/index.js
/node_modules/dist/css/styles.css
package.json
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我尝试了不同的变化,.npmignore但没有运气.
.npmignore与你想做的事情无关。该文件仅决定 npm 包代码的哪些部分最终出现在 npm 注册表中。所以它正如广告中所说的那样工作。
您的问题一定出在您的 npmconfig 中,或者是因为使用了旧版本的 npm。最新版本安装的内容如下:
/node_modules/@private/a/dist/index.js
/node_modules/@private/b/...
/node_modules/@private/c/...
package.json
Run Code Online (Sandbox Code Playgroud)
我已经证实最新的 npm 会发生这种情况。但曾经有一段时间,npm 将依赖项安装到嵌套结构中。例如参见这个。所以我建议:
npm get legacy-bundling。确保这是假的。即使使用最新的 npm,也很少有依赖关系嵌套合法发生的情况。看到这个。但我猜你的问题不是因为这个。您只需npm install @private/a在空文件夹中执行即可进行测试。
| 归档时间: |
|
| 查看次数: |
1434 次 |
| 最近记录: |