I've installed coreMIDI following this:
sudo npm install -g coremidi
The installation was successful, but I don't understand how to use it using node.js
This is the first line of my code:
var coremidi = require('coremidi')();
But the output is:
Error: Cannot find module 'coremidi'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/[NAME]/Desktop/nodeMidi/coremidi/test1.js:1:78)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
The require statement in node looks for a folder named node_modules in the current folder and if that exists looks in there for a folder named after your package. If it isn't found, it goes one directory higher and tries that again. It'll keep doing this until it reached the root folder of your file system.
The reason it can't find coremidi is because coremidi has been installed in the global node_modules folder since you used the -g flag. This is OS/node install dependent, but usually something like /usr/lib/local/share/npm/ or whatever. Since this path
You shouldn't use -g to install npm modules unless they're specifically meant to be installed globally (usually that means that include a script for you to run, like NPM itself, or jshint, or mocha, or tap, or etc...)