Create reusable library

How I can make external lib so I could use it in other parts of meteor app? I tried creating .js file and importing it where needed but that doesnt work. Any ideas how I can achieve this?

Can you show us how you’re declaring this and how you’re using it?

As I said I just created .js file and then imported using ‘import ‘./file.js’;’. Variables in file.js is unreachable

Before you can import a variable, you first need to export it.

// file.js
function foo() {
  // do stuff
}

export { foo }
// someOtherFile.js
import { foo } from './file';

foo()

More info on ES Modules

More info on Meteor’s implementation of ES Modules

There are multiple places you can “just create a .js file”. Not all of them will behave as you want.