Empecé a aprender JavaScript usando Atom para crear un gráfico en línea. Por lo tanto, no estoy muy familiarizado con NPM, package.json y todo ese tipo de cosas.
Quiero importar dos módulos usando el siguiente código:
import * as am4core from "@amcharts/amcharts4/core"; import * as am4charts from "@amcharts/amcharts4/charts";Lo que da el siguiente mensaje de error:
(node:17060) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use `node --trace-warnings ...` to show where the warning was created) C:\Users\PF1VMKH9_ADM\Documents\herverkaveling\test:4 import * as am4core from "@amcharts/amcharts4/core"; ^^^^^^ SyntaxError: Cannot use import statement outside a module at wrapSafe (internal/modules/cjs/loader.js:1001:16) at Module._compile (internal/modules/cjs/loader.js:1049:27) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (C:\Users\PF1VMKH9_ADM\.atom\packages\script\node_modules\pirates\lib\index.js:104:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at Object.<anonymous> (C:\Users\PF1VMKH9_ADM\.atom\packages\script\node_modules\@babel\node\lib\_babel-node.js:176:21) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) [Finished in 0.522s]Agregué "type": "module" al archivo package.json pero no resolvió el problema:
{ "name": "packages", "version": "1.0.0", "description": "", "main": "index.js", "type":"module", "dependencies": { "typescript": "^4.4.4" }, "devDependencies": {}, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }¿Qué estoy haciendo mal?