Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I'm trying to build a project that references a shared project alongside it.
My configs look like:
projectA/tsconfig.json
:
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"lib": [
"esnext.asynciterable"
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
"compileOnSave": true,
"include": [
"src"
"references": [
"path": "../shared",
"prepend": true
shared/tsconfig.json
:
"compilerOptions": {
"outFile": "build/out.js",
"composite": true,
"target": "es5",
"module": "amd",
"declaration": true,
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
"include": [
"src"
running
ts -b
from inside
projectA
yields:
src/index.ts:6:24 - error TS6305: Output file '.../shared/build/out.d.ts' has not been built from source file '.../shared/src/index.ts'.
6 import DummyClass from '../../shared/src';
Even though this file is indeed created.
What am I doing wrong?
–
–
For me, the solution was to run npx tsc -b
on the referenced-project directory, which requires npx to tell the typescript compiler (tsc
) to build (-b
). You can probably add this step to your compilation pipeline.
Perhaps an easier method is to tell typescript to do that itself by running tsc -b
in the npm build script of your main project (you can learn more here).
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.