1

I am new to NodeJS and TypeScript and I want to begin by setting up my project folder. I already have my tsconfig.json

{
"compilerOptions": {
    "outDir": "./build",
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny" : false
},
"files": [
    "./src/**/*.ts"
],
"exclude": [
    "node_modules"
]}

and package.json

    {
      "name": "crm",
      "version": "1.0.0",
      "description": "",
      "main": "app.js",
      "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC"
    }

This is my simple directory structure:

    crm/
     |-src/
       |- main/
          |- app.ts

when I compile it using the tsc command, I expected that the compiled directory will be

    crm/
     |-build/
       |- main/
          |- app.js

     |- src/
        |- main/
           |- app.ts

but the result is

    crm
     |- build/
        |- app.js

     |- src/
        |- main/
           |- app.ts

there is no main folder that is created.

I dont know if the problem is on tsconfig.json or in the tsc command

3
  • you want to maintain folder structure in build or compile inplace and put it in src? Commented Mar 12, 2017 at 4:43
  • i want it the ouput directory in build folder Commented Mar 12, 2017 at 4:46
  • ok.. added the answer..try it Commented Mar 12, 2017 at 4:49

1 Answer 1

1

You have set

"outDir": "./build",

in your tsconfig.json and no rootDir. Check compilerOptions here

Set the required output build path.

"outDir": "./build",
"rootDir": "./src"

You will get

crm
 |- build/
    |- main/
       |- app.js

Src: this issue

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.