FormidableLabs/nodejs-dashboard

Error: Cannot find module 'nodejs-dashboard'

AaronRobinson opened this issue · 3 comments

mac OS 10.13.3
node v 8.9.1
Tried on Hyper and iTerm

npm install -g nodejs-dashboard
nodejs-dashboard -- node -r nodejs-dashboard test.js

This starts the dashboard but gives me an error accessing the module...

screen shot 2018-03-29 at 14 06 53

This should be self-explanatory.

Since you installed the library globally, in your package.json file it should be like nodejs-dashboard -- node -r test.js and not nodejs-dashboard -- node -r nodejs-dashboard test.js as in the instructions

The -r nodejs-dashboard part is required and is the only require that we need for the dashboard. The problem is that sometime after like node8 or what not globally installed things via at least NVM which I use aren't findable.

Here's some info:

$ npm install -g nodejs-dashboard
$ node
> const dash = require("nodejs-dashboard");
Thrown:
{ Error: Cannot find module 'nodejs-dashboard'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18) code: 'MODULE_NOT_FOUND' }

When I dig and prefix the path to the actual nodejs-dashboard module, it works:

$ nodejs-dashboard -- nodemon -r "/Users/rye/.nvm/versions/node/v10.16.3/lib/node_modules/nodejs-dashboard" src/index.js 

or

 $ NODE_PATH="/Users/rye/.nvm/versions/node/v10.16.3/lib/node_modules" nodejs-dashboard -- node -r nodejs-dashboard src/index.js

I will try and see if I can get a more general solution...

As a quick hack if nothing else works we can probably have the nodejs-dashboard CLI augment NODE_PATH with the inferred location of global node_modules before spawning the process to execute after --