1
我正在嘗試使用NPM來鏈接依賴模塊B及其依賴項A.以this爲指導,我完成了以下工作。通過npm鏈接和打印本地開發的多模塊
項目A定義爲:
{
"name": "typescript-link-failure-a",
"version": "1.0.0",
"description": "",
"main": "dist/A.js",
"typescript": "dist/A.d.ts",
"scripts": {
"setup": "npm link"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-typescript": "^2.13.6",
"merge2": "^1.0.2"
}
}
A.ts
export class A {
"foo":string;
}
npm run-script setup
被執行以創建從這個目錄到全球node_modules的鏈接。
在項目B:
{
"name": "typescript-link-failure-b",
"version": "1.0.0",
"description": "",
"main": "dist/B.js",
"scripts": {
"preinstall": "npm link ../A"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-typescript": "^2.13.6",
"merge2": "^1.0.2"
}
}
B.ts
import {A} from "typescript-link-failure-a"
class B {
"foo":A;
}
我用NPM鏈接鏈接到項目A.我認爲聯工作,爲項目B的node_modules,我可以看到項目A.
然而,當我嘗試
import {A} from "typescript-link-failure-a"
,詮釋ellij,VS Code和TSC都沒有說明他們不瞭解名爲typescript-link-failure-a的模塊。
任何人都可以提供見解?