[solved] Import a function from another package

Hello,
I am on the server in package company1:company1 and I would like to import a function from company1:package-2

I tried many things like :

import myFunc from './packages/company1-package2/server/my-function;

But i receive : Error: Cannot find module

Do you know how to reference the path between packages ?
Thanks

I was able to do it like this :
in pacakge2 : api.export([‘myFunc’], ‘server’)
in package1 : import myFunc from ‘meteor/company1:package2’
Is this the right way to do it ?

1 Like

There are two methods. The first one is the one you used. The second one is, if you use api.mainModule, you can just export things there and then import it like you did previously.

4 Likes

this is awesome thanks for sharing I had no idea!