I have a module @vendorname/functions
that does not exist on the filesystem according to npm list
$ npm ls @vendorname/functions
serverless-commerce@1.0.0 C:\Users\mikem\OneDrive\Documents\myapp\myapp
`-- (empty)
It also does not exist according to a demo file:
$ node
> require("@vendorname/functions")
{ Error: Cannot find module '@vendorname/functions'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18) code: 'MODULE_NOT_FOUND' }
However I have a piece of software in the parent folder C:\Users\mikem\OneDrive\Documents\myapp\myapp
that uses the module and it works:
let vendornameFunctions = require("@vendorname/functions"),
log(`>>> MYSTERY FILE IS BEING IMPORTED ${JSON.dumps(vendornameFunctions, null, 2)}`);
Returns:
>>> MYSTERY FILE IS BEING IMPORTED {
"events": {},
"queues": {},
"tables": {},
"html": {},
"json": {},
"css": {},
"js": {},
"text": {},
"xml": {}
}
I can reliably replicate this behavior. How can I determine where on disk the module is being loaded from?
You can use require.resolve
to get the path to the module.
console.log(require.resolve("@vendorname/functions"));