module-alias icon indicating copy to clipboard operation
module-alias copied to clipboard

Doesn't work on node v18.12.1?

Open qxb3 opened this issue 2 years ago • 4 comments

index.js

require('module-alias/register')
...

package.json

{
  ...
  "_moduleAliases": {
    "#root": "./",
    "#src": "./src",
    "#routes": "./src/routes",
    "#lib": "./src/lib",
    "#utils": "./src/lib/utils",
    "#models": "./src/lib/models",
    "#decors": "./src/lib/decors",
    "#schemas": "./src/lib/schemas"
  }
  ...
}

versions

node: v18.21.1 module-alias: 2.2.2

qxb3 avatar Dec 06 '22 00:12 qxb3

and the error??

yunylz avatar Dec 27 '22 08:12 yunylz

@qxb3 How did you resolve this issue? In case of mine It throws Can't Find module ?

node:internal/modules/cjs/loader:1042
  throw err;
  ^
Error: Cannot find module '@routersV1/users/usersRouter'

package.json

"_moduleAliases": {
 "@routersV1/*": "./src/routers/v1/*"
}

Nodejs: v18.13.0

girixcode7 avatar Mar 25 '23 20:03 girixcode7

@girixcode7 i didn't i instead use this: #113

qxb3 avatar Mar 26 '23 01:03 qxb3

Follow this: https://medium.com/zero-equals-false/how-to-use-module-path-aliases-in-visual-studio-typescript-and-javascript-e7851df8eeaa

You might be missing the aliases in tsconfig.json

ugeshgupta000 avatar Jun 20 '23 12:06 ugeshgupta000