0

I need to test in the browser because I am using WebAudio. Okay, so since I'm using tape, I run

browserify -t babelify index.js | browser-run -p 3000

The problem is that I'm using Nitrous.io, so the test complains:

Error: Cannot find module '__mySource/models/audio' from '/home/nitrous/code/mrr/source/__mySource/test/audio/model/metronome'

So now I need I need to go into my code and customize all imports for the sake of Nitrous. So instead of

import {initialize} from '__mySource/models/audio';

I now need to hack all imports

import {initialize} from '/home/nitrous/code/mrr/source/__mySource/models/audio';

which is clearly unacceptable. Hopefully there is a simple fix for this problem.

Lo HaBuyshan
  • 359
  • 2
  • 12

1 Answers1

1

Typically I recommend that developers should use relative paths (starting with a './' or '../') when importing or requiring files. Absolute paths can vary from machine to machine so those are also problematic.

It is possible to define aliases that act like pseudo-packages but those can be tricky to configure and are often more confusing to developers than just using the standard commonjs naming.

So try using relative paths for your imports (or requires) that don't refer to files inside another actual package.

Jeff Barczewski
  • 446
  • 3
  • 7