Reputation: 21
I have files in a /models/
directory off the root of the Meteor application. That directory is in .meteorignore
so it’s not automatically loaded.
I can’t do import SomeModule from '/models/some-module.js'
from a file in the /imports/
directory. In some-module.js
, the error says that the export or import (at the top of the some-module.js
file) is an error.
export default function () {
^^^^^^
SyntaxError: Unexpected reserved word
at Object.exports.runInThisContext (vm.js:53:16)
at /Users/sunnyhirai/Projects/kb/.meteor/local/build/programs/server/boot.js:332:30
at Array.forEach (native)
at Function._.each._.forEach (/Users/sunnyhirai/.meteor/packages/meteor-tool/.1.5.4_2.1glyugb.deq2++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /Users/sunnyhirai/Projects/kb/.meteor/local/build/programs/server/boot.js:158:5
at /Users/sunnyhirai/Projects/kb/.meteor/local/build/programs/server/boot.js:388:5
at Function.run (/Users/sunnyhirai/Projects/kb/.meteor/local/build/programs/server/profile.js:510:12)
at /Users/sunnyhirai/Projects/kb/.meteor/local/build/programs/server/boot.js:387:11
In other words it is treating /models/
directory different than /imports/
directory. The same file in the /imports/
directory will import fine.
Please, if anybody knows how to fix this without moving all the files into /imports/
I would be grateful.
Upvotes: 2
Views: 339
Reputation: 399
Have you tried:
import {SomeModule}from '/models/some-module.js'
Upvotes: 0