Comments (3)
I faced this issue today as well. It appears that ESM modules are not loaded properly for the distribution version as if you run node --experimental-specifier-resolution=node .express/www.js
manually, you'll get something like:
% npm start
> [email protected] start
> node app.js
node:internal/modules/run_main:129
triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/homedir/esm-test/foo/bar' imported from /homedir/esm-test/app.js
Did you mean to import "./foo/bar.js"?
at finalizeResolution (node:internal/modules/esm/resolve:265:11)
at moduleResolve (node:internal/modules/esm/resolve:933:10)
at defaultResolve (node:internal/modules/esm/resolve:1169:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
at link (node:internal/modules/esm/module_job:86:36) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///homedir/esm-test/foo/bar'
}
Node.js v20.16.0
And it's caused by import usersRouter from "./routers/users";
line in generated dist/app.js
.
If you repalce it with import usersRouter from "./routers/users.js";
it works fine.
from gen-express-app.
Based on discussion in microsoft/TypeScript#52412 you can make a quick and drity workaround by:
- Setting following properties in
compilerOptions
of yourtsconfig.json
(you might need to overwrite some):
"module": "Node16",
"moduleResolution": "Node16",
- Changing
import usersRouter from "./routers/users";
toimport usersRouter from "./routers/users.js";
in yoursrc/app.ts
.
After that it should compile and work - but that's a workaround.
from gen-express-app.
This package is under developing right now. I`ll try to remake this package in general and make huge patch with new functions, commands and bug fixes. Main goal - make simillar to @nestjs/cli package for ExpressJS developers.
from gen-express-app.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gen-express-app.