Error: Cannot find module 'optimist'
AprilNEA opened this issue · comments
ubuntu@:~/c9sdk$ node server.js
/home/ubuntu/c9sdk/node_modules/c9/setup_paths.js:34
throw e;
^
Error: Cannot find module 'optimist'
at Module._resolveFilename (module.js:547:15)
at Function.modules._resolveFilename (/home/ubuntu/c9sdk/node_modules/c9/setup_paths.js:27:16)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at main (/home/ubuntu/c9sdk/server.js:74:20)
at Object. (/home/ubuntu/c9sdk/server.js:55:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
have you ran scripts/install-sdk.sh
?
maybe you should try npm install
?
@POTION4 I have tried to install npm install
but I'm getting:
luis.velasco2@is-di-dev-endpoints:/var/www/html/c9sdk$ sudo npm install
npm WARN deprecated connect@2.12.0: connect 2.x series is deprecated
npm WARN deprecated ejs@1.0.0: Critical security bugs fixed in 2.5.5
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated hoek@2.16.3: The major version is no longer supported. Please update to 4.x or newer
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/cloud9ide/tern_from_ts.git /root/.npm/_cacache/tmp/git-clone-d384bd0d
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-d384bd0d': Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-09-14T15_55_17_757Z-debug.log
What could be happening?
This should do the trick:
rm -r node_modules/
npm cache clean
npm install
cd scripts/
./install-sdk.sh
cd ..
node server.js -p 8181 -l 127.0.0.1
"npm install" is the problem because it wipes out node_modules leaving only the few it installs by default and nearly none of those required by c9. Doing "npm i optimist" and the rest, will eventually leave you with a few that c9 needs but don't exist elsewhere. I heard someone mention they cp'd the node_modules folder and replaced it after running the npm install but other than that... there has to be a cleaner way to do this... also the install-sdk script runs an npm install of sorts but editing this file is pointless because it does this weird thing where it gets replaced with a tmp.
I was able to get the install script to run correctly and successfully by changing that crap bit of line "$NPM -production" to "npm install npm -g" (as basically a run once because the tmp replace) but of course it still wipes out the node_modules so maybe throw some "npm i"s in afterwards...
install-sdk.sh already does npm install so no need to run that separately
just tried with a fresh git clone, ./scripts/install-sdk.sh was all that was needed, worked just fine.
npm 6, node 8
I had this problem, and I fixed it by doing 2 things:
-
It was on a new Linux install, and I hadn't yet installed node/npm, so when the script ran
npm install
, it didn't. Perhaps the install script should error out in that case? -
I kept getting a tmux error related to encoding. I added en_us UTF-8 as a locale, which fixed that problem.
After that, I ran the install script again, and it worked without an issue. Sounds like when this problem arises, something is halting the npm install
, or exiting before it runs.
is it solved?