I one meteor app I am trying to import a (local) npm package that was generated by another meteor app. This fails with the message
Error: Cannot find module 'meteor/meteor'
This is the source code for my package:
import { Meteor } from 'meteor/meteor'
export const isServer = () => Meteor.isServer
which transpiles into this package code:
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isServer = undefined;
var _meteor = require('meteor/meteor');
var isServer = exports.isServer = function isServer() {
return _meteor.Meteor.isServer;
};
The error is caused by the statement
var _meteor = require('meteor/meteor');
If I remove this line then everything is ok.
So, what is the correct way to create meteor packages that can be imported in other meteor apps?
I have lots of meteor code that I want to share between projects. I thought that creating npm modules should be a nice way of sharing them, but it seems that this import error will prevent me from doing so.
Or is there a way to make the meteor build tool ignore the offending import statement?