简体   繁体   English

导出导入浏览器投诉找不到模块

[英]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' .这个 Meteor 应用程序有一个模板事件,它产生一个Meteor.call ,并导致浏览器错误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 meteor list包括 ecmascript 0.15.1

Why is this and isn't the export/import correct as stated?为什么会这样,并且导出/导入是否如所述正确? How to get read of the error?如何读取错误信息? Thanks.谢谢。

Your relative path is wrong.你的相对路径是错误的。 The server folder is in the same directory as methods.js , so you'll need to import server文件夹与methods.js位于同一目录中,因此您需要导入

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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM