Fred J.
Fred J.

Reputation: 6039

Meteor can not find import module

Running this Meteor app is giving browser console error:

modules-runtime.js?hash=2b888cb…:155 Uncaught Error: Cannot find module '././lib'

//lib.js
let age = { // key.value pairs here };
let lib = { // key.value pairs here };
export {lib1, lib2}

//footer.js
import { lib, age } from '././lib.js'

enter image description here

Is there a problem with the import path?, if not, why the error? thx

Upvotes: 0

Views: 243

Answers (2)

Maxim Pokrovskii
Maxim Pokrovskii

Reputation: 353

it should be written like this ../lib.js or /client/templates/lib.js

Upvotes: 0

Jankapunkt
Jankapunkt

Reputation: 8423

You import as "named import" which is why you need to export as named export:

//lib.js
export const age = { // key.value pairs here };
export const lib = { // key.value pairs here };

also your path is not checking for the "parent" folders (../) but current folder (./)

//footer.js
import { lib, age } from '../../lib.js'

See also: Javascript (ES6), export const vs export default

Upvotes: 1

Related Questions