Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Error: Cannot find module 'optimist' #517

Open
AprilNEA opened this issue Aug 13, 2018 · 9 comments
Open

Error: Cannot find module 'optimist' #517

AprilNEA opened this issue Aug 13, 2018 · 9 comments

Comments

@AprilNEA
Copy link

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)

@georgir
Copy link

georgir commented Aug 15, 2018

have you ran scripts/install-sdk.sh?

@42yeah
Copy link

42yeah commented Sep 1, 2018

maybe you should try npm install?

@RodolVelasco
Copy link

@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 [email protected]: connect 2.x series is deprecated
npm WARN deprecated [email protected]: Critical security bugs fixed in 2.5.5
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: 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?

@ghost
Copy link

ghost commented Sep 19, 2018

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 

@wgailey
Copy link

wgailey commented Nov 25, 2018

"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...

@georgir
Copy link

georgir commented Nov 26, 2018

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

@ronaldroe
Copy link

I had this problem, and I fixed it by doing 2 things:

  1. 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?

  2. 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.

@lalizita
Copy link

lalizita commented Apr 15, 2020

is it solved?

@wgailey
Copy link

wgailey commented Apr 16, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants