owaspsamm / dashboard-webapp

21 stars 8 forks source link

Error: Cannot find module 'Q' #1

Open lwojgithub opened 3 years ago

lwojgithub commented 3 years ago

executed command in /server folder npm install npm install nodemon npm start

server@1.0.0 start /opt/samm/server node server.js

internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module 'Q' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/opt/samm/server/router/index.router.js:3:9) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! server@1.0.0 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the server@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

cd /server/node_modules/Q cat README.md

Deprecated Package

This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.

Please contact support@npmjs.com if you have questions about this package.

mgillam commented 3 years ago

https://github.com/OWASP/samm/blob/master/Supporting%20Resources/app/server/router/index.router.js#L3 seems to be this import. I don't see it in the package.json, not sure if it's been globally installed on the dev system. Seems to match https://www.npmjs.com/package/q based on usage. I'd suggest maybe an npm install --save q from within the server directory might fix this issue. Going forward, probably a PR with an updated package.json to commit the fix.

lwojgithub commented 3 years ago

Hi,

I'd suggest maybe an npm install --save q from within the server directory might fix this issue <- not working I also try npm install within /server catalog <- not working

Maybe instruction is not precisious?

my steps:

  1. git clone https://github.com/owaspsamm/dashboard-webapp.git
  2. navigate to /server directory and open command prompt and run the command: npm install npm install nodemon After installation, run the command: npm start (Do not close this terminal)
  3. navigate to /server2 directory and open command prompt and run the command: npm install npm install nodemon After installation, run the command: npm start (Do not close this terminal)
  4. to run the angular app, go to the parent directory /SAMM and run npm install -> ng serve in cmd. (Do not close this terminal)
mgillam commented 3 years ago

I'm not sure the project's history or where it lived before here. When I tried installing q, it changed to failing on the async package. So I ran an npm install --save async as well. That got me past the dependency errors. I didn't set up the DB, so that failed, but... image Can you confirm? I ran it with an npm start after.

lwojgithub commented 3 years ago

No, I got:

server@1.0.0 start /opt/samm/Supporting Resources/app/server node server.js

internal/modules/cjs/loader.js:323 throw err; ^

Error: Cannot find module '/opt/samm/Supporting Resources/app/server/node_modules/Q/index.js'. Please verify that the package.json has a valid "main" entry at tryPackage (internal/modules/cjs/loader.js:315:19) at Function.Module._findPath (internal/modules/cjs/loader.js:528:18) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:818:27) at Function.Module._load (internal/modules/cjs/loader.js:687:27) at Module.require (internal/modules/cjs/loader.js:903:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/opt/samm/Supporting Resources/app/server/router/index.router.js:3:9) at Module._compile (internal/modules/cjs/loader.js:1015:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10) at Module.load (internal/modules/cjs/loader.js:879:32) { code: 'MODULE_NOT_FOUND', path: '/opt/samm/Supporting Resources/app/server/node_modules/Q/package.json', requestPath: 'Q' } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! server@1.0.0 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the server@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/samm/.npm/_logs/2021-02-17T22_13_54_366Z-debug.log

what NodeJS / npm version are you using?

mgillam commented 3 years ago

I have node v14.15.4 and npm v7.5.3 .. but there were some package warnings as well, node v12.x would probably be a better choice in the near term if it can be made to work.

mgillam commented 3 years ago

I also cloned it from this repo, and from your directory structure it looks like you cloned from https://github.com/OWASP/samm.git So I did a fresh clone of that repo. Then did the following: npm install npm start -- failed on module Q npm install --save q npm start -- failed on module async npm install --save async npm start -- worked up to DB error.

Then I reset by restoring the package.json and package-lock.json and rm -rf the node_modules, and repeated the steps on node 12, and that worked the same for me.

lwojgithub commented 3 years ago

did you run these commands in the / server directory ?

mgillam commented 3 years ago

Yeah, that's correct. I ran them in /server.

Unknownl3 commented 3 years ago

Hi, have the same problem with module Q, tried:

So I did a fresh clone of that repo. Then did the following in /dashboard-webapp/server:
npm install
npm start -- failed on module Q
npm install --save q
npm start 

but there is still "Error: Cannot find module 'Q'". Any thoughts on what else to try? thx

lwojgithub commented 3 years ago

cd node_modules

ln -s q Q

cd ../models

ln -s User.js user.js

From: Unknownl3 @.> Sent: Tuesday, July 6, 2021 4:58 PM To: owaspsamm/dashboard-webapp @.> Cc: Łukasz Wojnowski @.>; Author @.> Subject: Re: [owaspsamm/dashboard-webapp] Error: Cannot find module 'Q' (#1)

Hi, have the same problem with module Q, tried:

So I did a fresh clone of that repo. Then did the following in /dashboard-webapp/server: npm install npm start -- failed on module Q npm install --save q npm start

but there is still "Error: Cannot find module 'Q'". Any thoughts on what else to try? thx

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/owaspsamm/dashboard-webapp/issues/1#issuecomment-874835158 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLDQ6CS4CEJCTZGFI6UKCDTWMKYRANCNFSM4XYL4I6Q . https://github.com/notifications/beacon/ACLDQ6B7XFVI5YGHJBRHNWDTWMKYRA5CNFSM4XYL4I62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGQSOZVQ.gif

satyendra22 commented 3 years ago

I'm not sure the project's history or where it lived before here. When I tried installing q, it changed to failing on the async package. So I ran an npm install --save async as well. That got me past the dependency errors. I didn't set up the DB, so that failed, but... image Can you confirm? I ran it with an npm start after.

I'm getting exactly same error. do we have any solution for this? @mgillam @lwojgithub @dkefer

mgillam commented 3 years ago

To be clear, I'm not a maintainer of this project. I have verified that it's behaving the same way for me today as it was on Feb 17. Which is to be expected, since I hadn't set up the Db, and still haven't. The I believe the Error connecting to Db message is correct behavior for my context.

satyendra22 commented 3 years ago

@mgillam thx for quick reply , did u fixed the issue as you mentioned because currently I'm getting exactly same issue.

Joda-repo commented 3 years ago

@mgillam thx for quick reply , did u fixed the issue as you mentioned because currently I'm getting exactly same issue.

Hi @satyendra22 comments: https://github.com/owaspsamm/dashboard-webapp/issues/1#issuecomment-780900118 and https://github.com/owaspsamm/dashboard-webapp/issues/1#issuecomment-875340098

helped me to fix that issue.

P.S. conection to Db looks fine too.

sleightsec commented 2 years ago

saw a few issues on npm imports/requires for the server package Q was one of them, async missing was another one. I would expect that you would want to correct case on the requires vs having to give a symlink from Q -> q. Other module import case sensitivity seen on requiring ../models/users when the file name is in caps so should be ../models/Users(?) or renaming the file to lowercase...