Hi,
I have npm package I want to import across multiple places (e.g. my custom UI and forge UI builds) that I keep in a separate directory and have configured via npm link as a local package. When I do a regular deploy, everything works fine, however when I configure a tunnel to a custom UI endpoint the bundling fails with TS2307: Cannot find module 'mypackage' or its corresponding type declarations.
on a file in the src dir of my forge app.
are there issues with local npm packages when tunneling?
1 Like
Hi Michael,
I’m getting in contact with the relevant team to understand why your situation works when deployed but not in the tunnel.
So I had a chat with them. Problem relates to docker not picking up symlinks correctly.
A workaround is to use yalc which will perform a copy of your files into node_modules
instead.
Let me know if this doesn’t work for you.
2 Likes
@JoshuaHwang so when looking at GitHub - wclr/yalc: Work with yarn/npm packages locally like a boss. i can see we would need the following:
in the shared library:
yalc publish --private
in the location where we want to used the shared source code:
yalc add xxx
When doing this, I can indeed see the package and the source code in the node_modules directory.
In webstorm I can find the packages and import.
Now if I do this, I still get an error:
Error: Bundling failed: Module not found: Error: Can’t resolve …
Thanks.
Hi Tim
The error your facing is quite different to the original poster’s. Would you be able to provide the full error message to help investigations?
Cheers.
Hi @JoshuaHwang ,
originally I had the same problem when using npm link:
TS2307: Cannot find module 'mypackage' or its corresponding type declarations.
Then I installed yalc:
npm i yalc -g
Then installed the local shared library using
yalc publish --private
Then into the macro where I would like to use the shared library, I installed it using:
yalc add shared
Then when running forge deploy I get no error message and have a working macro.
When using forge tunnel, I do get another error:
Error: Bundling failed: Module not found: Error: Can’t resolve ‘xxx’ in ‘/app/src’, Module not found: Error: Can’t resolve ‘yyy’ in ‘/app
/src’, Module not found: Error: Can’t resolve ‘zzz’ in ‘/app/src’
I do see the package and source code installed in the node_modules directory.
Thanks in advance.