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

[ERROR] Cannot find module '~/utils/params' #430

Open
angelhdzdev opened this issue May 1, 2023 · 2 comments
Open

[ERROR] Cannot find module '~/utils/params' #430

angelhdzdev opened this issue May 1, 2023 · 2 comments

Comments

@angelhdzdev
Copy link

Describe the bug
[ERROR] Cannot find module '~/utils/params' in NestJS application.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10 Home Version 10.0.19044 Build 19044
  • Browser: Chrome 112.0.5615.138 (Official Build) (64-bit)

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
I installed all versions from the latest to the 3.3.3. Same error. Using NestJS, TypeScript, pnpm. Tried installing dependencies with pnpm install --shamefully-hoist.

@angelhdzdev
Copy link
Author

Update

I'm debugging the dist folder built by tsc.
It has to be related to the ~/* path alias configured in tsconfig.json of the original TypeScript project.

I'm gonna download the TypeScript project, run the build script, and see what happens.

@angelhdzdev
Copy link
Author

Update 2

I added this code at the top of the dist/index.js:

"use strict";
require('module-alias/register');

const path = require('path');
const aliases = {
  '~': path.join(__dirname, 'dist')
};
require('module-alias').addAliases(aliases);

Now the NestJS app is running without errors.

I see you're using "module-alias": "^2.2.2". There must be something wrong with it that fails to do its job in the project built for production.

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

No branches or pull requests

1 participant