Fred J.
Fred J.

Reputation: 6029

export import browser complaint cannot find module

This Meteor app has a template event that maks a Meteor.call, and is causing browser error Cannot find module 'server/plateCheck.js'. The file responsible is:

//app/imports/api/vehicles/methods.js

import { Meteor } from 'meteor/meteor'
import { Vehicles } from './vehicles.js'
import { plateCheck } from "../server/plateCheck.js"; //<<<<<<<<<< 

Meteor.methods({
    'extractPlateData': function (plate) {
        console.log('method called: ', plate)
        plateCheck(plate)
    }
)},


//app/imports/api/vehicles/server/plateCheck.js

import {Vehicles} from '../imports/api/vehicles/vehicles.js'

const plateCheck = async (plateNumber) => {...}
module.exports = plateCheck;

meteor list includes ecmascript 0.15.1

Why is this and isn't the export/import correct as stated? How to get read of the error? Thanks.

Upvotes: 0

Views: 218

Answers (1)

Christian Fritz
Christian Fritz

Reputation: 21364

Your relative path is wrong. The server folder is in the same directory as methods.js, so you'll need to import

import { plateCheck } from "./server/plateCheck.js";

Or you can make all imports absolute:

//app/imports/api/vehicles/methods.js
import { plateCheck } from "/imports/api/server/plateCheck.js";

...

//app/imports/api/vehicles/server/plateCheck.js
import {Vehicles} from '/imports/api/vehicles/vehicles.js'

Upvotes: 1

Related Questions