mayneyao / gatsby-source-notion-database

Load data from Notion's database [WIP]
MIT License
92 stars 20 forks source link

Error: [ERR_REQUIRE_ESM]: Must use import to load ES Module: #4

Closed kerorojason closed 4 years ago

kerorojason commented 4 years ago

When I install this plugin, my gatsby app shows this error. Which will disappear when I comment out it from the gatsby-config.js

Error: [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/hewang/Workspace/gatsby/tutorial-part-two/node_modules/gatsby-source-notion-database/gatsby-node.js require() of ES modules is not supported. require() of /Users/hewang/Workspace/gatsby/tutorial-part-two/node_modules/gatsby-source-notion-database/gatsby-node.js from /Users/hewang/Workspace/gatsby/tutorial-part-two/ node_modules/gatsby/dist/bootstrap/resolve-module-exports.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which define s all .js files in that package scope as ES modules. Instead rename gatsby-node.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/hewang/Workspace/gatsby/tutorial-part-two/node _modules/gatsby-source-notion-database/package.json.

kerorojason commented 4 years ago

Solved it by removing "type": "module" from ./node _modules/gatsby-source-notion-database/package.json.