[Solved] How do i use npm modules in meteor


#1

I have downloaded the npm package in my meteor app, i can also see it inside the “node-module” folder. So how do i use that module ?


#2

Here is a guide for that :
https://guide.meteor.com/using-npm-packages.html


#3

Thanx…and yeah i tried using this before and now its working…it wasn’t working before coz i was trying to import in client side script…when i imported in server side script…it worked…


#4

You should definitely be able to import from the client (assuming the module in question doesn’t attempt to use native node methods or access the file system).

Which module, and what errors was it giving you?


#5

well it gives me the error in the import syntax saying such module doesnt exist… “import { CoinPayments } from ‘coinpayments’;” this command
when i use this import statement in server script then no errors.


#6

i am trying to use this module in my meteor js : https://www.npmjs.com/package/coinpayments


#7

OK I have fixed my issue so how can i close this topic


#8

You can’t, but you could explain what you did, in case it helps someone else :slight_smile:


#9

here is how i did it…follow the installation part of npm pakcages from here:https://guide.meteor.com/using-npm-packages.html(only installation of npm) when done go to ur client side js file(preferably). No need to import or stuff…just type the following

const pkg = require('<package-name>');
and thats it you just imported the package and its ready to use. No need of import statements.