Ошибка при импорте модулей node.js

(node:19400) 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\Nikita\Desktop\node\index.js:1
import chalkPackage from 'chalk'
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:353:18)
    at wrapSafe (node:internal/modules/cjs/loader:1039:15)
    at Module._compile (node:internal/modules/cjs/loader:1073:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47**
import chalkPackage from 'chalk'

console.log(chalk.blue('nodejs'))

Без импорта все отлично работает, пробовал переименовывать, первоначальное название файла main.js, сейчас - index.js. Пару дней назад начал изучать js, поэтому просьба объяснить максимально на пальцах


Ответы (0 шт):