H
Hono4mo ago
valerio

throw new ERR_MODULE_NOT_FOUND [Nodejs Template]

Following this guide https://hono.dev/docs/getting-started/nodejs#dockerfile i'm trying to create two scripts: one for build ("tsc") and anthoer for start the build ("node dist/index.js) buit i got this error
2024-08-19 11:47:09 node:internal/modules/esm/resolve:265
2024-08-19 11:47:09 throw new ERR_MODULE_NOT_FOUND(
2024-08-19 11:47:09 ^
2024-08-19 11:47:09
2024-08-19 11:47:09 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/dist/foo' imported from /app/dist/index.js
2024-08-19 11:47:09 at finalizeResolution (node:internal/modules/esm/resolve:265:11)
2024-08-19 11:47:09 at moduleResolve (node:internal/modules/esm/resolve:933:10)
2024-08-19 11:47:09 at defaultResolve (node:internal/modules/esm/resolve:1169:11)
2024-08-19 11:47:09 at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
2024-08-19 11:47:09 at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
2024-08-19 11:47:09 at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
2024-08-19 11:47:09 at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
2024-08-19 11:47:09 at link (node:internal/modules/esm/module_job:86:36) {
2024-08-19 11:47:09 code: 'ERR_MODULE_NOT_FOUND',
2024-08-19 11:47:09 url: 'file:///app/dist/foo'
2024-08-19 11:47:09 }
2024-08-19 11:47:09
2024-08-19 11:47:09 Node.js v20.16.0
2024-08-19 11:47:09 node:internal/modules/esm/resolve:265
2024-08-19 11:47:09 throw new ERR_MODULE_NOT_FOUND(
2024-08-19 11:47:09 ^
2024-08-19 11:47:09
2024-08-19 11:47:09 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/dist/foo' imported from /app/dist/index.js
2024-08-19 11:47:09 at finalizeResolution (node:internal/modules/esm/resolve:265:11)
2024-08-19 11:47:09 at moduleResolve (node:internal/modules/esm/resolve:933:10)
2024-08-19 11:47:09 at defaultResolve (node:internal/modules/esm/resolve:1169:11)
2024-08-19 11:47:09 at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
2024-08-19 11:47:09 at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
2024-08-19 11:47:09 at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
2024-08-19 11:47:09 at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
2024-08-19 11:47:09 at link (node:internal/modules/esm/module_job:86:36) {
2024-08-19 11:47:09 code: 'ERR_MODULE_NOT_FOUND',
2024-08-19 11:47:09 url: 'file:///app/dist/foo'
2024-08-19 11:47:09 }
2024-08-19 11:47:09
2024-08-19 11:47:09 Node.js v20.16.0
to reproduce the errors: - npm create hono@latest ./foo-hono (nodejs template) - npm install typescript --save-dev - Add "build": "tsc" to script section of package.json - Add "start": "node dist/index.js" to script section of package.json - Add "exclude": ["node_modules"] to tsconfig.json. - Add "outDir": "./dist" to the compilerOptions section tsconfig.json. - Add "type": "module" to package.json. - create a file foo.ts with a funcition that runs a console.log - use it in the index.ts run - npm run build - npm run start
Can someone help me?
Node.js - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
1 Reply
Thái An
Thái An3mo ago
I also got into this problem
Want results from more Discord servers?
Add your server