Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm package using @types/meteor cannot find module meteor/meteor

I have published an npm package (meteor-model) that has a dependency on @types/meteor. The project itself works fine and

import Meteor from 'meteor/meteor'

correctly resolves to

node_modules/@types/meteor

However, it does not work when I install this package in another project:

Cannot find module 'meteor/meteor'

thrown in

node_modules\meteor-model\dist\MeteorModelDecorators.js:38:16

The repo is here: https://github.com/navio-xyz/meteor-model

like image 555
Chris Avatar asked Sep 12 '25 04:09

Chris


2 Answers

Now you can just use the following command to install meteor types:

meteor npm install @types/meteor --save
like image 161
Benjamin Frazier Avatar answered Sep 13 '25 20:09

Benjamin Frazier


You simply cannot use 'meteor/*' package to import any module, because there is no meteor package system. If you want to use Meteor or Mongo etc., you can just use it as global variable directly. To enable the type check for such global variables, here is what to do:

  1. install @types/meteor package using
npm install --save-dev @types/meteor
  1. add types into your compilerOptions in your tsconfig.json file like this:
{
  "compilerOptions": {
     ...
     "types": [
       "meteor"
     ]
  }
}
like image 42
D C Avatar answered Sep 13 '25 21:09

D C