Answers for "tsnode syntaxerror: cannot use import statement outside a module"

2

SyntaxError: Cannot use import statement outside a module node js

// Note: "import" should generally be used for modules/package projects, otherwise use
// "require"
// In your NodeJS project's package.json add the following "type" field to allow use of "import":
{
  "type": "module"
}
Posted by: Guest on August-30-2021
6

cannot use import statement outside a module typescript

// Fix 1
Change .js files to .cjs
// Fix 2
Add "type": "module" to package.json
Posted by: Guest on December-03-2020

Code answers related to "tsnode syntaxerror: cannot use import statement outside a module"

Code answers related to "Javascript"

Browse Popular Code Answers by Language