Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nest cannot handle src/main.mts #11021

Closed
3 of 15 tasks
beckend opened this issue Feb 2, 2023 · 4 comments
Closed
3 of 15 tasks

nest cannot handle src/main.mts #11021

beckend opened this issue Feb 2, 2023 · 4 comments
Labels
needs triage This issue has not been looked into

Comments

@beckend
Copy link

beckend commented Feb 2, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

> nest start

Error: Cannot find module '/home/admin/Coding/codegenerator/dist/main'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Function.Module._load (node:internal/modules/cjs/loader:885:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

works fine when using main.ts.

Minimum reproduction code

https://github.com/beckend/bug-nestjs-main.mts

Steps to reproduce

mkdir /tmp/work && cd /tmp/work
npm i -g @nestjs/cli
npx nest new project-name
cd project-name
mv src/main.ts src/main.mts
npm run start

nest start

Error: Cannot find module '/tmp/work/project-name/dist/main'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Function.Module._load (node:internal/modules/cjs/loader:885:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Expected behavior

> [email protected] start
> nest start

[Nest] 58877  - 02/02/2023, 11:45:40 PM     LOG [NestFactory] Starting Nest application...
[Nest] 58877  - 02/02/2023, 11:45:40 PM     LOG [InstanceLoader] AppModule dependencies initialized +5ms
[Nest] 58877  - 02/02/2023, 11:45:40 PM     LOG [RoutesResolver] AppController {/}: +2ms
[Nest] 58877  - 02/02/2023, 11:45:40 PM     LOG [RouterExplorer] Mapped {/, GET} route +1ms
[Nest] 58877  - 02/02/2023, 11:45:40 PM     LOG [NestApplication] Nest application successfully started +0ms

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

9.3.1

Packages versions

"dependencies": {
    "@nestjs/common": "^9.3.1",
    "@nestjs/core": "^9.3.1",
    "@nestjs/platform-express": "^9.3.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.0"
  },
  "devDependencies": {
    "@nestjs/cli": "^9.1.9",
    "@nestjs/schematics": "^9.0.4",
    "@nestjs/testing": "^9.3.1",
    "@types/express": "^4.17.16",
    "@types/jest": "29.4.0",
    "@types/node": "18.11.18",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^5.50.0",
    "@typescript-eslint/parser": "^5.50.0",
    "eslint": "^8.33.0",
    "eslint-config-prettier": "^8.6.0",
    "eslint-plugin-prettier": "^4.2.1",
    "jest": "29.4.1",
    "prettier": "^2.8.3",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "29.0.5",
    "ts-loader": "^9.4.2",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "4.1.2",
    "typescript": "^4.9.5"
  },

Node.js version

18.13.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@beckend beckend added the needs triage This issue has not been looked into label Feb 2, 2023
@micalevisk micalevisk reopened this Feb 2, 2023
@beckend
Copy link
Author

beckend commented Feb 2, 2023

why would I build it?

@micalevisk
Copy link
Member

yeeah, using nest start you don't have to build it yourself. I thought you were using npm run start:prod my bad

@micalevisk
Copy link
Member

micalevisk commented Feb 2, 2023

you can circumvent that by using the entryFile option in your nest-cli.json with the value "main.mjs" so it will run node dist/src/main.mjs instead

But it still won't start due to the lack of support of ESM (see #8736)

@kamilmysliwiec
Copy link
Member

#8736

@nestjs nestjs locked and limited conversation to collaborators Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

3 participants