Logo

dev-resources.site

for different kinds of informations.

Fix NX Node executor ERR_REQUIRE_ESM Error

Published at
6/10/2022
Categories
nx
node
esm
cjs
Author
stomvi
Categories
4 categories in total
nx
open
node
open
esm
open
cjs
open
Author
6 person written this
stomvi
open
Fix NX Node executor ERR_REQUIRE_ESM Error

昨晚睡前踩了個雷,來分享一下:

NX 新專案忘了裡面已經裝過 nanoid,重裝了一次,然後 @nrwl/node:node 就開始報錯,找到引用 nanoid 的 model,在 sequelize hooks 裡,用報錯的解法改用 dynamic import 可以解決,查 NX issue 也看到幾個 node executor 不支援 static import ESM 的問題。

然後剛剛去看 nanoid,3 天前 nanoid@4 migrate 到純 ESM 不支援 CJS 了⋯⋯降級回 nanoid@3 就解決了,等 NX issue #10414 merge 看有沒有改善吧。

Reference

esm Article's
30 articles in total
Favicon
Bundling without a bundler with esm.sh
Favicon
Building NPM packages for CommonJS with ESM dependencies
Favicon
Web Development Without (Build) Tooling
Favicon
Dual Node TypeScript Packages - The Easy Way
Favicon
Oh CommonJS! Why are you mESMing with me?! Reasons to ditch CommonJS
Favicon
The Ongoing War Between CJS & ESM: A Tale of Two Module Systems
Favicon
How I optimized Carousel for EditorJS 2x in size.
Favicon
Transitioning from CommonJS to ESM
Favicon
Node.js, TypeScript and ESM: it doesn't have to be painful
Favicon
Set up Hot Reload for Typescript ESM projects
Favicon
Set up a Node.js project + TypeScript + Jest using ES Modules
Favicon
ESM & CJS: The subtle shift in bundlejs' behaviour
Favicon
Mastering the Art of ESM and CJS Package Handling
Favicon
Modules & Modules & Modules, Oh My!
Favicon
How to build TypeScript to ESM and CommonJS
Favicon
ES Modules & Import Maps: Back to the Future
Favicon
How to use ESM on the web and in Node.js
Favicon
Custom ESM loaders: Who, what, when, where, why, how
Favicon
Fix NX Node executor ERR_REQUIRE_ESM Error
Favicon
Creating a Node.js module for both CommonJS & ESM consumption
Favicon
STOP using require() in node backend
Favicon
JavaScript Module Ecosystem
Favicon
Declarative database modelling
Favicon
Expressjs: Javascript written in ECMAScript 2015 (ES6)
Favicon
How to use ES Modules with Node.js
Favicon
What does it take to support Node.js ESM?
Favicon
Build modular app with Alpine.js
Favicon
TS and ts-jest meet “type”: “module”
Favicon
ESM doesn't need to break the ecosystem
Favicon
constructor() dynamic import()

Featured ones: