jrburke/requirejs — Issue #150: Modules installed using npm, which use requirejs internally, cannot find AMD modules in the installed package
Author: jbeard4
Created: 2011-12-14 01:49:21+00:00
State: open

I'm developing a project that uses requirejs for loading AMD modules in nodejs, and this works very well. I'm now trying to create an npm package, and what I've found is that the main JavaScript file in the npm package (e.g. index.js) cannot use requirejs to import AMD sub-modules in the same package.

The following is a reduced example of a npm package which uses requirejs internally, and fails to load AMD modules within the package: http://stuff.echo-flow.com/requirejs-npm-package-test.tgz

The tarball contains instructions for installing and testing. Tested on node 0.4.7, requirejs 1.0.2, and npm 0.3.18

The documentation refers to loading node modules relative to the index.js file, so it seems like this would probably be regarded as a bug:

//Pass the top-level main.js/index.js require
//function to requirejs so that node modules
//are loaded relative to the top-level JS file.

From http://requirejs.org/docs/node.html