Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: МОЙ ПУТЬ\gulpfile.js require() of ES modules is not supported. #53

Closed
Eeesbk opened this issue Aug 22, 2021 · 4 comments

Comments

@Eeesbk
Copy link

Eeesbk commented Aug 22, 2021

node v14.17.5

internal/modules/cjs/loader.js:1089
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\web_test\gulpfile.js
require() of ES modules is not supported.
require() of МОЙ ПУТЬ\gulpfile.js from МОЙ ПУТЬ\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned^4.0.0\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename gulpfile.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\web_test\package.json.

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at execute (МОЙ ПУТЬ\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18)
at Liftoff.handleArguments (МОЙ ПУТЬ\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\index.js:201:24)
at Liftoff.execute (МОЙ ПУТЬ\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:201:12)
at module.exports (МОЙ ПУТЬ\AppData\Roaming\npm\node_modules\gulp\node_modules\flagged-respawn\index.js:51:3)
at Liftoff.<anonymous> (МОЙ ПУТЬ\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:191:5) {

code: 'ERR_REQUIRE_ESM'
}

@agragregra
Copy link
Owner

agragregra commented Aug 23, 2021

Проверил в разных системах, в разных Node - LTS, Latest. Всё работает.
Обновите окружение: https://webdesign-master.ru/blog/tools/wsl-nodejs-new.html

@AndrewPalchykovsky
Copy link

@Eeesbk у меня было тоже самое после того как решил исправить зависимости в пакетах. Пробовал использовать разные версии ноды. Не помогло.
Вот что сделал чтобы восстановить:

  1. Снести глобально gulp
  2. Установить глобально gulp
  3. Снести node_modules с тем, что наворотил
  4. Наново использовать npm i в проекте
  5. Запустить gulp

@VKabz
Copy link

VKabz commented Nov 18, 2021

Такая же проблема.

@VKabz
Copy link

VKabz commented Nov 18, 2021

Решение:

C:\Users\UserName\AppData\Roaming\npm\node_modules

Удалить папку gulp

Установить заново: npm install --global gulp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants