I think I found a solution that works a little better. I’m using an npm workspace, which actually allows me to use the workspaces as if they’re absolute paths. My directory structure is as follows:
root/
api/
app.js
package.json
shared/
test.js
package.json
ui/
package.json
package.json
In the root package.json
, I have specified the workspaces
config to be the following:
"workspaces": [
"ui",
"api",
"shared"
]
And then in app.js
, I can reference something from shared like import test from "shared/test.js"
. I didn’t realize this added benefit of workspaces, but it definitely solves the issue I was having.
CLICK HERE to find out more related problems solutions.