[Startup Engineering] HW4: Cannot find module 'express'
[sourcecode language=”bash”]
ubuntu@ip-172-31-5-125:~/bitstarter$ node web.js
module.js:340
throw err;
^
Error: Cannot find module ‘express’
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> (/home/ubuntu/bitstarter/web.js:19:15)
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)
[/sourcecode]
I can’t run node web.js, so try to find express library.
[sourcecode language=”bash”]
ubuntu@ip-172-31-5-125:~/bitstarter$ ls
checks.json index.html package.json restler test.tar.gz
grader.js node_modules Procfile test web.js
ubuntu@ip-172-31-5-125:~/bitstarter$ cd node_modules
ubuntu@ip-172-31-5-125:~/bitstarter/node_modules$ ls
cheerio commander
ubuntu@ip-172-31-5-125:~$ ls
bitstarter hello-world MKprime.js node_modules tmp
hello.js index.html MKprime.txt npm-debug.log
hello.js.save market-research.csv modules simple.sh
hello.js.save.1 market-research.js node.js something.txt
hello.txt market-research-wrapper.js node-js-sample somthing.txt
ubuntu@ip-172-31-5-125:~$ cd node_modules
ubuntu@ip-172-31-5-125:~/node_modules$ ls
accounting csv hello-world restler
[/sourcecode]
I couldn’t find anywhere. so I try to install express.
[sourcecode language=”bash”]
ubuntu@ip-172-31-5-125:~$ npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm ERR! Error: EACCES, mkdir ‘/usr/local/lib/node_modules/express’
npm ERR! { [Error: EACCES, mkdir ‘/usr/local/lib/node_modules/express’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/usr/local/lib/node_modules/express’,
npm ERR! fstream_type: ‘Directory’,
npm ERR! fstream_path: ‘/usr/local/lib/node_modules/express’,
npm ERR! fstream_class: ‘DirWriter’,
npm ERR! fstream_stack:
npm ERR! [ ‘/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23’,
npm ERR! ‘/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53’,
npm ERR! ‘Object.oncomplete (fs.js:107:15)’ ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
[/sourcecode]
It had errors. I refered to resolve here.
[sourcecode language=”bash”]</span>
ubuntu@ip-172-31-5-125:~$ sudo chown -R $USER /usr/local
ubuntu@ip-172-31-5-125:~$ npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/connect/2.8.4
npm http GET https://registry.npmjs.org/commander/1.2.0
npm http GET https://registry.npmjs.org/mkdirp/0.3.5
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/send/0.1.3
npm http GET https://registry.npmjs.org/cookie-signature/1.0.1
npm http GET https://registry.npmjs.org/debug
npm http 200 https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/mkdirp/0.3.5
npm http 200 https://registry.npmjs.org/commander/1.2.0
npm http 200 https://registry.npmjs.org/cookie/0.1.0
npm http 200 https://registry.npmjs.org/connect/2.8.4
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
npm http GET https://registry.npmjs.org/commander/-/commander-1.2.0.tgz
npm http GET https://registry.npmjs.org/cookie/-/cookie-0.1.0.tgz
npm http GET https://registry.npmjs.org/connect/-/connect-2.8.4.tgz
npm http 200 https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz
npm http 200 https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz
npm http 200 https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/methods/-/methods-0.0.1.tgz
npm http 200 https://registry.npmjs.org/cookie-signature/1.0.1
npm http 200 https://registry.npmjs.org/send/0.1.3
npm http GET https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.1.tgz
npm http GET https://registry.npmjs.org/send/-/send-0.1.3.tgz
npm http 200 https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/debug/-/debug-0.7.2.tgz
npm http 200 https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/commander/-/commander-1.2.0.tgz
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
npm http 200 https://registry.npmjs.org/cookie/-/cookie-0.1.0.tgz
npm http 200 https://registry.npmjs.org/connect/-/connect-2.8.4.tgz
npm http 200 https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz
npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz
npm http 200 https://registry.npmjs.org/methods/-/methods-0.0.1.tgz
npm http 200 https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.1.tgz
npm http 200 https://registry.npmjs.org/send/-/send-0.1.3.tgz
npm http 200 https://registry.npmjs.org/debug/-/debug-0.7.2.tgz
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/qs/0.6.5
npm http GET https://registry.npmjs.org/formidable/1.0.14
npm http GET https://registry.npmjs.org/bytes/0.2.0
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http GET https://registry.npmjs.org/uid2/0.0.2
npm http 200 https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/mime/-/mime-1.2.9.tgz
npm http 200 https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz
npm http 200 https://registry.npmjs.org/pause/0.0.1
npm http 200 https://registry.npmjs.org/uid2/0.0.2
npm http GET https://registry.npmjs.org/pause/-/pause-0.0.1.tgz
npm http GET https://registry.npmjs.org/uid2/-/uid2-0.0.2.tgz
npm http 200 https://registry.npmjs.org/qs/0.6.5
npm http 200 https://registry.npmjs.org/bytes/0.2.0
npm http GET https://registry.npmjs.org/qs/-/qs-0.6.5.tgz
npm http 200 https://registry.npmjs.org/formidable/1.0.14
npm http GET https://registry.npmjs.org/bytes/-/bytes-0.2.0.tgz
npm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.14.tgz
npm http 200 https://registry.npmjs.org/mime/-/mime-1.2.9.tgz
npm http 200 https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz
npm http 200 https://registry.npmjs.org/uid2/-/uid2-0.0.2.tgz
npm http 200 https://registry.npmjs.org/pause/-/pause-0.0.1.tgz
npm http 200 https://registry.npmjs.org/bytes/-/bytes-0.2.0.tgz
npm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.14.tgz
npm http 200 https://registry.npmjs.org/qs/-/qs-0.6.5.tgz
/usr/local/bin/express -> /usr/local/lib/node_modules/express/bin/express
express@3.3.4 /usr/local/lib/node_modules/express
├── methods@0.0.1
├── fresh@0.1.0
├── range-parser@0.0.4
├── cookie-signature@1.0.1
├── buffer-crc32@0.2.1
├── cookie@0.1.0
├── debug@0.7.2
├── mkdirp@0.3.5
├── commander@1.2.0 (keypress@0.1.0)
├── send@0.1.3 (mime@1.2.9)
└── connect@2.8.4 (uid2@0.0.2, pause@0.0.1, qs@0.6.5, bytes@0.2.0, formidable@1.0.14)
ubuntu@ip-172-31-5-125:~$
[/sourcecode]
But this error is continuing when command node web.js.
I try to install setup.sh again. It maybe install package.json. BUT!!!!!!!! 🙁
I try again
[sourcecode language=”bash”] $ npm install express [/sourcecode]
after successfully installing, it working! why didn’t work before?
[sourcecode language=”bash”]
ubuntu@ip-172-31-5-125:~/bitstarter$ npm install express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-2.5.11.tgz
npm http 200 https://registry.npmjs.org/express/-/express-2.5.11.tgz
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/qs
npm http 200 https://registry.npmjs.org/mime/1.2.4
npm http 200 https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http 200 https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/connect/-/connect-1.9.2.tgz
npm http 200 https://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http 200 https://registry.npmjs.org/connect/-/connect-1.9.2.tgz
npm http GET https://registry.npmjs.org/formidable
npm http 200 https://registry.npmjs.org/formidable
express@2.5.11 node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.9.2 (formidable@1.0.14)
ubuntu@ip-172-31-5-125:~/bitstarter$ node web.js
Listening on 5000
^[[B^Cubuntu@ip-172-31-5-125:~/bitstarter$ node web.js
Listening on 8080
[/sourcecode]
I don’t know well… refer to this issue