I'm doing a project in typescript
and I want to execute the command that I usually use to compile the .ts
files from a script in the file package.json
and so I could run the script as:
npm run nombrescript
This is the tsconfig.json:
{
"compilerOptions": {
"lib": [ "es2015" ],
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"noImplicitAny": true,
"sourceMap": false,
"outDir": "src"
},
"include": [
"**/*", "."
],
"exclude": [
"node_modules"
]
}
and that's how I define the scripts:
"scripts": {
"build": "ntsc",
"build:watch": "ntsc --watch"
}
The problem I'm having
Running ntsc
or ntsc --watch
from the console compiles the files in the destination.
When I run it as npm run build
or npm run build:watch
I get the following error:
TypeError: Path must be a string. Received undefined
If I now change the script as follows:
"build": "ntsc ."
I receive the following error:
Error: references.d.ts not found in. or any of its parents
Why does not the same command work if I include it in scripts in the package.json?
My ultimate goal is to be able to execute that script in the postinstall. How can I solve to execute it as npm run build
?