Skip to content

Error [ERR_REQUIRE_ESM] on parsePhoneNumberFromString #432

Open
@balenaultra

Description

I've getting this error when run it on a server of my company

On my computer it runs fine.

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

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Ultra WS\UltraAtendimentoRest - 3412\node_modules\libphonenumber-js\build\parsePhoneNumberFromString.js
require() of ES modules is not supported.
require() of C:\Ultra WS\UltraAtendimentoRest - 3412\node_modules\libphonenumber-js\build\parsePhoneNumberFromString.js from C:\Ultra WS\UltraAtendimentoRest - 3412\node_modules\libphonenumber-js\core\index.cjs 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 parsePhoneNumberFromString.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Ultra WS\UltraAtendimentoRest - 3412\node_modules\libphonenumber-js\package.json.

←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m    at Module.require (internal/modules/cjs/loader.js:952:19)←[39m
←[90m    at require (internal/modules/cjs/helpers.js:88:18)←[39m
    at Object.<anonymous> (C:\Ultra WS\UltraAtendimentoRest - 3412\node_modules\←[4mlibphonenumber-js←[24m\core\index.cjs:3:34)
←[90m    at Module._compile (internal/modules/cjs/loader.js:1063:30)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m {
  code: ←[32m'ERR_REQUIRE_ESM'←[39m
}

Node version: v14.15.1

To fix it, for now, i just remove the "type": "module" from the package.json but it happens in every project from my pc.

Anyone can help me?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions