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

not working on compiling ts to js #20

Open
m0hdasif opened this issue Feb 11, 2020 · 4 comments
Open

not working on compiling ts to js #20

m0hdasif opened this issue Feb 11, 2020 · 4 comments

Comments

@m0hdasif
Copy link

@Rush,

I really liked your package, but I ran into issue while I was implementing the links in typescript.
It is working fine in typescript but got the following issue on compiling the project into JavaScript.

Error: Cannot find module '@utils/httpService

Please tell me, how can I resolve the issue?

@Rush
Copy link
Owner

Rush commented Feb 11, 2020

Could you provide a sample repo where the problem occurs? I think I dealt with a similar issue but would need to see what was the problem in your case.

@khuezy
Copy link

khuezy commented Feb 20, 2020

@m0hdasif
tsconfig.json:

    "rootDir": "src",
    "baseUrl": ".",
    "paths": {
      "@utils/*": ["src/utils/*"]
    }

package.json:

"_moduleAliases": {
    "@utils": "src/utils"
},

You'll want to prefix the link-module-alias before all your node command
e.g.: nodemon.json:

 "exec": "link-module-alias && node...

Personally, I'd just alias the root:
tsconfig.json:

"paths": {
      "~/*": ["src/*"]
    }

package.json:

"~": "src"

@m0hdasif
Copy link
Author

m0hdasif commented Mar 1, 2020

Thanks @khuezy for suggestion, I made it work by making following tweaks in expressJs application:

tsconfig.json:

    "rootDir": "src",
    "baseUrl": ".",
    "paths": {
      "@utils/*": ["src/utils/*"]
    }

package.json:

  • creating links post-build
"scripts": {
    "preinstall": "which link-module-alias && link-module-alias clean || echo",
    "postinstall": "link-module-alias",
    "build": "rm -rf build/ && tsc && link-module-alias",
    "start": "node build/src/index.js"
  },
"_moduleAliases": {
    "@utils": "build/src/utils"
}

Hi @Rush,
I am facing the said issue while using serverless-plugin-typescript plugin in server-less application. I need to check if I could run link-module-alias command with above tweaks post compilation to JavaScript while running/deploying the server-less application.

@albertcito
Copy link

Same issue !

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

4 participants