I wrote a module which I published to npm a moment ago (https://npmjs.org/package/wisp)
So it installs fine from the command line:
$ npm i -g wisp
However, when I run it from the command line, I keep getting an error that optimist isn't installed:
$ wisp
Error: Cannot find module 'optimist'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:12:10)
at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:96:4)
at Module._compile (module.js:449:26)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25)
at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29)
at fs.stat.notSources.(anonymous function) (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18)
However, I have specified in package.json as a dependancy:
{
"name": "wisp",
"author": "Brendan Scarvell <bscarvell@gmail.com>",
"version": "0.1.0",
"description": "Global nodejs file server",
"dependencies": {
"optimist": "~0.3.4"
},
"repository": "git://github.com/tehlulz/wisp",
"bin": {
"wisp" : "./wisp"
}
}
Does anyone know what to do to get this running? I know its to do with the bin part adding the executable to bin and the node_modules in that directory being empty. No idea how to resolve this.
add this to beginning of prog(mac):
module.paths.push('/usr/local/lib/node_modules');
I had the same error as the OP, but digging through the logs I could see
sh: node: command not found
.It turns out that the /usr/bin/node program (symlink) is no longer installed with
apt install nodejs
. Once symlinked/usr/bin/node' to
nodejs,
npm install -g @angular/cli` succeeded.The proper way to install this on debian is
apt install nodejs-legacy
.I got the "optimist" module error and I just did "npm install" to resolve it. went past that error.
https://github.com/mbloch/mapshaper/issues/12
I had to add C:\Users\{Username}\AppData\Roaming\npm to my env variables and then i could install stuff.
For anyone else running into this, I had this problem due to my
npm
installing into a location that's not on myNODE_PATH
.My NODE_PATH was empty, and running
npm install --global --verbose promised-io
showed that it was installing into/opt/lib/node_modules/promised-io
:My script fails on
require('promised-io/promise')
:I probably installed node and npm from source using
configure --prefix=/opt
. I've no idea why this has made them incapable of finding installed modules. The fix for now is to point NODE_PATH at the right directory:My
require('promised-io/promise')
now succeeds.Had the same problem on one of the test servers running
Ubuntu
underroot
. Then created a new user usinguseradd -m myuser
and installed everything (nvm
,node
, packages) asmyuser
. Now it's working fine.