Answers for "node js cannot use an 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
5

cannot use import statement outside a module

//Add type=module to your index.js script tag (not just the package script tag)

<script type="module" src="./index.js"></script>
Posted by: Guest on September-26-2021

Code answers related to "node js cannot use an import statement outside a module"

Code answers related to "Javascript"

Browse Popular Code Answers by Language