Skip to content

es import with node 13+ #3

Description

@bugdriven

I want to start using es Import From, instead of common.js require(), but gets the this error:

`Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: E:\Scrape\LM\Views\db.js
require() of ES modules is not supported.
require() of E:\Scrape\LM\Views\db.js from E:\Scrape\LM\node_modules\express-engine-jsx\require.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 db.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from E:\Scrape\LM\package.json.

at new NodeError (node:internal/errors:329:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1109:13)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at requireJSX (E:\Scrape\LM\node_modules\express-engine-jsx\require.js:22:11)
at View.engine (E:\Scrape\LM\node_modules\express-engine-jsx\index.js:17:20)
at View.render (E:\Scrape\LM\node_modules\express\lib\view.js:135:8)
at tryRender (E:\Scrape\LM\node_modules\express\lib\application.js:640:10)

`

I am not using any builder (like Webpack)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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