vercel: @now/node: Cannot find module '~' when using paths in TypeScript
Trying to use the micro-cookie-session lib with @now/node@canary and I’m getting this error below.
Don’t have the error when I run the code locally (with micro-dev)
Unable to import module 'launcher': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.901 (/var/task/user/backend/index.js:4546:18)
at __webpack_require__ (/var/task/user/backend/index.js:22:30)
at Object.68 (/var/task/user/backend/index.js:69:18)
at __webpack_require__ (/var/task/user/backend/index.js:22:30)
at Object.262 (/var/task/user/backend/index.js:401:17)
at __webpack_require__ (/var/task/user/backend/index.js:22:30)
edit: This happens in @now/node now.
For context, using typescript
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 14
- Comments: 27 (5 by maintainers)
Any updates on this? My serverless function in
api/directory uses imports alias and I’m trying to find a way to make it work on vercel. Is there any way to achieve this at the moment?Any follow-up here? Any suggestions on how to use Vercel withcustom paths?
On the docs https://zeit.co/docs/runtimes#official-runtimes/node-js/using-typescript-with-the-node-js-runtime:
Is this the right issue to track where these two features are going to be supported by now?
I think we originally thought this was a ncc bug with broken typescript
paths.But I confirmed it works fine with ncc 🤔
The canary builder has improved error messages so I went ahead and deployed zeit-now-typescript-broken-example and I see the error
Cannot find module '~app'. So it looks like this is a bug with the builder, but it requires further investigation.Yup just spent 1h this afternoon trying to figure this out.
I think setting
"paths"in TS is common enough to have well documented this incompatibility and possible workarounds. I’m happy to contribute with documentation PRs 🙌🏼@styfle just following up on this bug, since it’s still blocking us from using TS in production with Zeit. Can you let me know if you were able to reproduce the above behavior with my repository?
I’ve got the same error with typescript when I’m trying to use custom imports (
pathsorbaseUrlintsconfig.json)Reporoduction Example repo - https://github.com/pie6k/zeit-now-typescript-broken-example/
vercel devstill has this problem. I checked the code indev-server.js, it seems that ts-node only usestargetin provided tsconfig.json.So is there any workaround? If not - then
nowshould throw an error ispathsintsconfigare not empty.I have the same error message since yesterday (21 Mar) (
Unable to import module 'launcher': Error...)I can build and run locally with
nccbut once deployed to Now I get this error message. My repo worked fine for the last several weeks, it’s only since yesterday I’m getting this error.UPDATE:
I’ve set
"use": "@now/node@canary"in mynow.jsonconfig to try to track down the bug, but it’s no longer necessary, the deployment runs without any errors with this setting! 💯(note: I didn’t even know that the
@canarysuffix existed before…)Hate to say bump, but this hasnt gotten any visiblity, and i have absolutely no way to debug this.