Skip to content Skip to sidebar Skip to footer

Meteor Npm.require() Cannot Find A File In Parent Directory

I'm trying to get an abandoned nodejs library to work under Meteor. Why does Npm.require('./crypto-js/crypto') work fine, but Npm.require('../convert') is throwing the error Error:

Solution 1:

Already answered to this on IRC but posting here for the reference.

The author wanted to use a fork of npm module hosted on GitHub. To import the npm module from certain repo and certain commit, we can use GitHub's tarball url.

  • Create a smart package in /packages/package-name
  • In /packages/package-name/package.js describe the package, add files, export variables
  • add Npm.depends to package.js file looking like this:

    Npm.depends({'NPM-MODULE-NAME': "https://github.com/REPOAUTHOR/REPONAME/tarball/COMMIT-SHA1"});

  • in one of the smart package's files do ExportSymbol = Npm.require('NPM-MODULE-NAME')

  • export the export symbol

example: https://github.com/Slava/meteor-npm-fork-example

Post a Comment for "Meteor Npm.require() Cannot Find A File In Parent Directory"