3

I am transpiling typescript into javascript for an application targetting Node v.14. I want my output to have require instead of import statements. My config file looks like this:

{
  "compilerOptions": {
    "outDir": "./build",
    "allowJs": true,
    "target": "es2015",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "module": "es2015",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "./src/**/*"
  ]
}

I get import statements instead. Please advise.

1 Answer 1

2

Change the module to commonjs. If you do this, you also don't need to specify "moduleResolution": "node" as node is the default for when module is commonjs.

{
  "compilerOptions": {
    // ...
    "module": "commonjs"
  },
  // ...
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.