Cannot find module 'express-session' - node.js

I am trying to run sparkleshare-dashboard. This is an open source project you can see it here
https://github.com/tommyd3mdi/sparkleshare-dashboard.
The project use Node.JS and Redis and i have no experience with both. I did setup the environment as described in the help file and then i try to run file app.js from command line using 'node' command but i got this error.
Error: Cannot find module 'express-session'
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> (E:\Imports\sparkleshare-dashboard\app.js:5: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)
Maybe i didn't provide enough information but i am expecting that may be some of you guys has done some work on sparkleshare project and may someone can help me in this.

The reason is likely your ">" operator for express in the package.json.
Express 4.0 is out now and the complete middleware concept changed.
You need to install these middlewares manually.
"express-session" is one of the 4.0 middlewares.
I recommend to read
http://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0
and
https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x
Additionally some users were confused that the github repo is named just "session" but
npm install express-session
is correct.

Make sure you have installed express-session. You can check for the directory inside your node_modules folder or you can also chekc your dependencies inside your package.json file

Related

I am getting an error when i run my node.js app ( also using rabbit )

Error: Cannot find module 'amqplib/callback_api'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (C:\Users\hello\Downloads\Private-Chat-App-Socket.io-
master\Private-Chat-App-Socket.io-master\app.js:3:9)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
I have tried to solve the error by installing amqp using npm but it does not work and i have also searched for solutions on the internet but no luck.
Pic of the error
I just noticed you're declaring amqp twice. In line 3 and 6:
var amqp = require('amqplip/callback_api'),
So I will suggest you check your code and choose the one you'll wanna use.
That aside, I think what you're trying to use is amqplib and not amqp
To resolve your problem, I will suggest you delete the node_modules dir completely, then run npm install, after which you run these:
npm install --save amqplib
This should solve your problem.

Use nodeclipse plugin

I'm using nodeclipse plugin in eclipse to start working with nodejs and expressjs ,but when i create expressjs project and try run app.js file i get this error
/home/ali/node_modules/express/lib/express.js:99
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
^
Error: Most middleware (like favicon) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
at Function.Object.defineProperty.get (/home/ali/node_modules/express/lib/express.js:99:13)
at Object.<anonymous> (/home/ali/node-WS/express01/app.js:18:16)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
How can i fix this problem?
This means You have to install module separately. Maybe you're using latest version of expressJS.
installing modules separately will solve your problem!

Error: Cannot find module 'ms'

I've been trying to get my app running for a few days now, but keep getting errors. I'm closer than I have been so far, but am now getting the "Cannot find module error" when trying to launch my application.
Below is the error I'm getting now.
C:\MY-APP\dataService>node dataAPI.js
module.js:338
throw err;
^
Error: Cannot find module 'ms'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\MY-APP\node_modules\express\node_modules\debug
\debug.js:14:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
I also searched the forums for an answer to this question and found this post on Stack Overflow, but it was in reference to Azure, which I'm not using.
I'm new to Node.js so forgive me if I sound like I don't know what I'm talking about because that's largely the truth.
please see this Link :
https://www.npmjs.com/package/ms
and use :
npm install ms -S
on your project its automatically save ms package to the node-module.
Just in case the above answer doesn't work for someone with this problem: I had this same problem when trying to run tests using the Puppeteer framework. I ended up having to cd into the node_modules/puppeteer folder and manually running npm install for it to finally work in my case.

ERROR: Cannot find module './lib/base/events'

I'm getting the error ERROR: Cannot find module './lib/base/events' when trying to run Ghost 0.5.0.
I keep uninstalling and installing events even with the -g flag, but it doesn't pick it up. I'm stuck here and don't know what else to do.
more info:
Error: Cannot find module './lib/base/events'
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 Bookshelf.initialize (/usr/share/nginx/www/lm-ghost-0.5/node_modules/bookshelf/bookshelf.js:28:16)
at Bookshelf (/usr/share/nginx/www/lm-ghost-0.5/node_modules/bookshelf/bookshelf.js:10:31)
at Object.<anonymous> (/usr/share/nginx/www/lm-ghost-0.5/core/server/models/base.js:24:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
SO, I installed the bookshelf module manually but now get another error:
/usr/share/nginx/www/lm-ghost-0.5/node_modules/downsize/node_modules/xregexp/xregexp-all.js:1396
L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Wow, OK, now I installed xregexp manually and moving along...
Just for the record, anybody else comes across this issue, I had to basically watch out for any error and whenever I saw node_modules/XXX I simply manually installed module XXX and continued to do so for all errors until it worked.

Require cannot find custom module after moving to server

I am trying to deploy a node app that runs fine on my local Mac Lion, however. On the virtual Ubuntu box, it is giving an error:
module.js:340
throw err;
^
Error: Cannot find module '../lib/review'
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/websites/Node_apps/min-driver-node/routes/reviews.js:2:14)
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 Module.require (module.js:364:17)
There is my own custom modules in ./lib folder that are 'require' from the routes as following:
var Review = require('../lib/review');
What have I tried?
Ensured the same Node.js version running via
nvm(https://github.com/creationix/nvm)
Removed node_modules just to
re-install them by running "npm install"
Why is the 'require' unable import the custom modules from 'lib' folder on Server while works on Mac? Thank You
Try using the complete path to the file instead of using the relative path (../).
It looks like the 'require' module is case sensitive on Ubuntu but not on Mac....all my modules in lib folder starts with upper case(i.e. lib/Review.js), but when required in other parts of the code, it is lower case - require('../lib/review'). This is causing issue on Ubuntu but not on Mac lion. By updating the code to 'require('../lib/Review'), solves the problem
Is this a bug and i should be reporting this?
Try set file permissions chmod -R 744 '../lib/review'

Resources