'Error pulling my own TypeScript package from NPM after using direct reference to GitHub branch for debugging
I have two packages that are both held on NPM, we can refer to them as A and B
A uses B, so when I PR and merge with B it automatically updates NPM with those details, which I then import into A in my package.json by listing "package-a": "1.2.3"
I switched to importing not from npm, but from GitHub directly by putting "package-b": "https://github.com/organization/package-b#MyBranch" instead of a specific version like 1.2.3 in my package.json. This worked fine for debugging things between these two packages.
Now, switching back is giving me trouble.
Everything looked fine in package B, build is successful and tests are passing, so I create a PR and merge it, so B on npm it is updated automatically.
In the package.json for A I change back the reference from "package-a":"https://github.com/organization/package-a#MyBranch" to "package-a":"1.2.4", and do a yarn install in package A to bring the updates from package B.
The problem is that now when I yarn install in package A, I get an error trying to install package B
error C:\Users\...\...\package-a\node_modules\package-b: Command failed.
Exit code: 1
Command: yarn build
Arguments:
Directory: C:\Users\...\...\package-a\node_modules\package-b
Output:
yarn run v1.22.17
$ tsc --build --verbose ./tsconfig.build.json
10:17:58 AM - Projects in this build:
* tsconfig.build.json
error TS5083: Cannot read file 'C:/Users/.../.../package-a/node_modules/package-b/tsconfig.build.json'.
error Command failed with exit code 1.
So it seems to me it's trying to build B as a TypeScript package when I install it through A, but there isn't a ts.config.json file for it to read and it's erroring. I had to modify the postinstall script in package A to make the direct referencing in GitHub for package B to work, but I've removed that now. I have cleared the yarn cache as well.
Funnily enough running with regular npm i not yarn and it worked fine.
What's happening here? Both packages have identical ts.config.json files too.
ts.config.json
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"lib": [
"ES2018"
],
"module": "CommonJS",
"moduleResolution": "node",
"strict": true,
"target": "ES2018",
"sourceMap": true,
"composite": true,
"outDir": "lib",
"rootDir": "src",
"strictNullChecks": true
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
