4

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

1
  • silly question but... is meteor initialised in the second project ? Commented Jan 12, 2018 at 18:20

3 Answers 3

7

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

meteor npm install @types/meteor --save
Sign up to request clarification or add additional context in comments.

1 Comment

Fixed my issue. Why this isn't in the doc ?
3

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"
     ]
  }
}

Comments

0

You still need to install the meteor package. Your library cannot import from there without that dependency.

npm install meteor --save

@types/* is just the definition, so TypeScript knows how to typecheck. You still need the implementation.

1 Comment

It's a meteor project. There is no npm meteor package. www.meteor.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.