You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see there are a few GitHub issues and related to tsconfig path aliases not working the generate:types command, but I'm not able to get path aliases working at all with an express app like the Payload template-blank repo. I did find that tsconfig paths aren't supposed to work in express apps without the tsconfig-paths package installed and configured. However, that didn't solve the issue. Here's an example of the instructions I followed to set up tsconfig-paths: https://javascript.plainenglish.io/how-to-use-the-tsconfig-json-paths-option-in-node-js-24ccb94b4506
When I start payload with yarn dev I see errors like this Module not found: Error: Can't resolve 'Blocks/CallToAction'. If I instead use this exact same tsconfig configuration with Payload's next-payload-demo repo then the path aliases work fine. Here's the tsconfig I'm using:
I am expecting to be able to then do imports like this: import { CallToAction } from 'Blocks/CallToAction';. Here's the full text of the error I'm seeing:
Module not found: Error: Can't resolve 'Components/admin/graphics/Logo' in '/Users/xxx/Documents/webdev/payload-demo/src'Did you mean './Components/admin/graphics/Logo'?Requests that should resolve in the current directory need to start with './'.
To set up tsconfig-paths I installed the package and then set up nodemon.json:
Here's also a stackblitz project with that setup... it doesn't actually run(I guess I'd need to someone set a mongodb url in the env file without making that public) but the important code changes are there: https://stackblitz.com/edit/github-gtdnqx?file=nodemon.json
I've done a good bit of experimented with different configuration options but no luck. Having these aliases working is a very big convenience feature for me, so I'd love to get it working in the payload blank template.
Can anyone direct me to an example of an express based Payload app using tsconfig paths for path aliases or else point to what I'm doing wrong here?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I see there are a few GitHub issues and related to tsconfig path aliases not working the generate:types command, but I'm not able to get path aliases working at all with an express app like the Payload template-blank repo. I did find that tsconfig paths aren't supposed to work in express apps without the
tsconfig-paths
package installed and configured. However, that didn't solve the issue. Here's an example of the instructions I followed to set uptsconfig-paths
: https://javascript.plainenglish.io/how-to-use-the-tsconfig-json-paths-option-in-node-js-24ccb94b4506When I start payload with
yarn dev
I see errors like thisModule not found: Error: Can't resolve 'Blocks/CallToAction'
. If I instead use this exact same tsconfig configuration with Payload's next-payload-demo repo then the path aliases work fine. Here's the tsconfig I'm using:I am expecting to be able to then do imports like this:
import { CallToAction } from 'Blocks/CallToAction';
. Here's the full text of the error I'm seeing:To set up
tsconfig-paths
I installed the package and then set upnodemon.json
:Here's also a stackblitz project with that setup... it doesn't actually run(I guess I'd need to someone set a mongodb url in the env file without making that public) but the important code changes are there:
https://stackblitz.com/edit/github-gtdnqx?file=nodemon.json
I've done a good bit of experimented with different configuration options but no luck. Having these aliases working is a very big convenience feature for me, so I'd love to get it working in the payload blank template.
Can anyone direct me to an example of an express based Payload app using tsconfig paths for path aliases or else point to what I'm doing wrong here?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions