Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

import fetch from ("node-fetch"); ^^^^^^ SyntaxError: Cannot use import statement outside a module

/*
In the nearest parent package.json file, add the top-level "type"
field with a value of "module". This will ensure that all .js and .mjs
files are interpreted as ES modules. You can interpret individual files
as CommonJS by using the .cjs extension.
*/
// package.json
{
  "type": "module"
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #import #fetch #Cannot #import #statement #module
ADD COMMENT
Topic
Name
2+1 =