dependency-check-team / dependency-check

checks which modules you have used in your code and then makes sure they are listed as dependencies in your package.json
https://npmjs.org/dependency-check
545 stars 38 forks source link

handle case where a relative file is missing #25

Closed max-mapper closed 7 months ago

max-mapper commented 9 years ago

e.g. if you don't check a file into git, right now it blows up like this:

/Users/maxogden/src/js/dependency-check/node_modules/resolve/lib/sync.js:33
    throw new Error("Cannot find module '" + x + "' from '" + y + "'");
          ^
Error: Cannot find module './pulse-till-done.js' from '/Users/maxogden/Desktop/test/node_modules/npm/lib/utils'
    at Function.module.exports (/Users/maxogden/src/js/dependency-check/node_modules/resolve/lib/sync.js:33:11)
    at getDeps (/Users/maxogden/src/js/dependency-check/index.js:113:22)
    at /Users/maxogden/src/js/dependency-check/index.js:154:9
    at /Users/maxogden/src/js/dependency-check/node_modules/async/lib/async.js:249:17
    at /Users/maxogden/src/js/dependency-check/node_modules/async/lib/async.js:125:13
    at Array.forEach (native)
    at _each (/Users/maxogden/src/js/dependency-check/node_modules/async/lib/async.js:46:24)
    at async.each (/Users/maxogden/src/js/dependency-check/node_modules/async/lib/async.js:124:9)
    at _asyncMap (/Users/maxogden/src/js/dependency-check/node_modules/async/lib/async.js:248:13)
    at Object.map (/Users/maxogden/src/js/dependency-check/node_modules/async/lib/async.js:219:23)

but it shouldn't crash

ensonic commented 9 years ago

Not sure if it is the same - I've got this and wonder which index file it is refering to:

# find . -name "index"
./.git/index

# dependency-check ./package.json

/usr/local/lib/node_modules/dependency-check/node_modules/resolve/lib/sync.js:33
    throw new Error("Cannot find module '" + x + "' from '" + y + "'");
          ^
Error: Cannot find module './index' from '/home/user/project/node_modules'
    at Function.module.exports [as sync] (/usr/local/lib/node_modules/dependency-check/node_modules/resolve/lib/sync.js:33:11)
    at getDeps (/usr/local/lib/node_modules/dependency-check/index.js:116:22)
    at /usr/local/lib/node_modules/dependency-check/index.js:157:9
    at /usr/local/lib/node_modules/dependency-check/node_modules/async/lib/async.js:249:17
    at /usr/local/lib/node_modules/dependency-check/node_modules/async/lib/async.js:125:13
    at Array.forEach (native)
    at _each (/usr/local/lib/node_modules/dependency-check/node_modules/async/lib/async.js:46:24)
    at async.each (/usr/local/lib/node_modules/dependency-check/node_modules/async/lib/async.js:124:9)
    at _asyncMap (/usr/local/lib/node_modules/dependency-check/node_modules/async/lib/async.js:248:13)
    at Object.map (/usr/local/lib/node_modules/dependency-check/node_modules/async/lib/async.js:219:23)
max-mapper commented 9 years ago

@ensonic maybe try running with DEBUG=* dependency-check ./package.json and see if that might hint at which module is causing it to look for ./index? it might be that you need to change it to ./index.js in your code to get it to work at the moment

ensonic commented 9 years ago

Thanks for suggesting the obvious :)

  dependency-check entry paths +0ms [ '/home/user/project/node_modules/.bin/noflo-nodejs' ]
  dependency-check require("commander") is a dependency +40ms
  dependency-check require("http") is core +2ms
  dependency-check require("../index") is relative +0ms
  dependency-check require("noflo") is a dependency +1ms
  dependency-check require("noflo-runtime-websocket") is a dependency +0ms
  dependency-check require("flowhub-registry") is a dependency +0ms
  dependency-check require("querystring") is core +0ms
  dependency-check resolve +0ms [ '/home/user/project/node_modules',
  './index' ]
/usr/local/lib/node_modules/dependency-check/node_modules/resolve/lib/sync.js:33
    throw new Error("Cannot find module '" + x + "' from '" + y + "'");

in package.json I have:

"main": "./node_modules/.bin/noflo-nodejs",

Appending a '.js' there does not make a difference. Not sure why it even tries the non-existing 'node_modules/index'.

max-mapper commented 9 years ago

Ah its this line https://github.com/noflo/noflo-nodejs/blob/22a7ca8f3fef141bae96478f4f0d3a3dc940a67a/src/noflo-nodejs.coffee#L4

I opened an issue to track this https://github.com/maxogden/dependency-check/issues/26

On Tue, May 12, 2015 at 6:44 AM, Stefan Sauer notifications@github.com wrote:

Thanks for suggesting the obvious :)

dependency-check entry paths +0ms [ '/home/user/project/node_modules/.bin/noflo-nodejs' ] dependency-check require("commander") is a dependency +40ms dependency-check require("http") is core +2ms dependency-check require("../index") is relative +0ms dependency-check require("noflo") is a dependency +1ms dependency-check require("noflo-runtime-websocket") is a dependency +0ms dependency-check require("flowhub-registry") is a dependency +0ms dependency-check require("querystring") is core +0ms dependency-check resolve +0ms [ '/home/user/project/node_modules', './index' ] /usr/local/lib/node_modules/dependency-check/node_modules/resolve/lib/sync.js:33 throw new Error("Cannot find module '" + x + "' from '" + y + "'");

in package.json I have:

"main": "./node_modules/.bin/noflo-nodejs",

Appending a '.js' there does not make a difference. Not sure why it even tries the non-existing 'node_modules/index'.

— Reply to this email directly or view it on GitHub https://github.com/maxogden/dependency-check/issues/25#issuecomment-101286738 .

Clement-TS commented 8 years ago

Experiencing the same issue, either using dependency-check localy (npm install --save-dev) or system-wide (npm install -g). Do you have any clue?