I want to use module-alias with esm. I have already found an answer here. The problem is that I am using it manually, like this:
import * as path from 'path';
import * as moduleAlias from 'module-alias';
moduleAlias.addAlias('@', path.join(process.cwd(), 'dist', 'server'));
How can I fix it if it is not directly called by module-alias/register but from this code?
 
                        
I solved the problem. To do it I just stop using module-alias which is at this point an obsolete npm package (+3 year of inactivity as of 19/07/2022) and useful only for the commonjs module resolution.
Citing the right answer from this github error, the solution is creating a file
custom-loader.mjsand add it as a loader when calling nodeThen, when calling the script, add
--loader=./custom-loader.mjsUPDATE: I created this npm module to automatically take care of this.