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

Module-Alias not working with pkg #137

Open
avinashk2946 opened this issue Oct 9, 2023 · 0 comments
Open

Module-Alias not working with pkg #137

avinashk2946 opened this issue Oct 9, 2023 · 0 comments

Comments

@avinashk2946
Copy link

I am using plain JavaScript for building APIs using Node.js and Express.js. I have the following module alias configuration, which is heavily used across my project in require statements:

const moduleAlias = require("module-alias"),
  path = require("path"),
  root = path.join(__dirname, "../"),
  api = `${root}/src`,
  aliasConfig = {
    "@root": root,
    "@custom-lib": `${root}/custom-lib`,
    "@api": api
  };
  
global.baseDir = root;

module.exports = () => moduleAlias.addAliases(aliasConfig);

I'm getting the following error after running the pkg . command:

Warning Cannot find module '@root/routes' from 'C:\Workspace\Projects\server.js'

It seems that the module alias configuration is causing an issue when trying to find the @root/routes module. Any suggestions on how to resolve this would be greatly appreciated.

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