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

Cannot find module 'dist/main' after upgrading to 10.1.12 #2247

Closed
1 of 4 tasks
michael-land opened this issue Aug 18, 2023 · 7 comments
Closed
1 of 4 tasks

Cannot find module 'dist/main' after upgrading to 10.1.12 #2247

michael-land opened this issue Aug 18, 2023 · 7 comments

Comments

@michael-land
Copy link

michael-land commented Aug 18, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

❯ pnpm dev

> @app/[email protected] dev /Users/.../apps/app-scheduler
> nest start --watch

>  SWC  Running...
Successfully compiled: 3 files with swc (6.47ms)

 Error  Cannot find module 'dist/main'
Require stack:
- /Users/.../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@nestjs/cli/actions/start.action.js
- /Users/.../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@nestjs/cli/actions/index.js
- /Users/.../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@nestjs/cli/commands/command.loader.js
- /Users/.../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@nestjs/cli/commands/index.js
- /Users/.../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@nestjs/cli/bin/nest.js

Watching for file changes.

Minimum reproduction code

Steps to reproduce

No response

Expected behavior

no error

Package version

10.1.12

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).

@michael-land
Copy link
Author

should be related to #2245

@michael-land
Copy link
Author

michael-land commented Aug 23, 2023

@kamilmysliwiec

The problem persists even after upgrading to version 10.1.13. in this pr #2228, it resolve absolute path. The problem revolves around the inability of the nodejs require.resolve function to function correctly with absolute paths.

https://github.com/nestjs/nest-cli/blob/master/lib/configuration/defaults.ts#L29C14-L29C27.

By default, the "outdir" is set to "dist" but I recommend changing it to "./dist"

To address this problem, a workaround involves adding the following line to your tsconfig.json file to override the default value:

{
    "outDir": "./dist",
}

to reproduce, see
https://codesandbox.io/p/sandbox/github/nestjs/typescript-starter/tree/master?file=%2Fpackage.json%3A29%2C26

CleanShot 2023-08-22 at 22 03 20@2x

@michael-land michael-land reopened this Aug 23, 2023
@kamilmysliwiec
Copy link
Member

Should we revert #2228 for the time being then?

@zhangyuang
Copy link
Contributor

The problem remains

@kamilmysliwiec
Copy link
Member

Could you test with 10.1.14?

@michael-land
Copy link
Author

Could you test with 10.1.14?

10.1.14 is functional as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants