Closed justinmchase closed 7 years ago
This worked around the issue for me:
var opt = { cache: {} }
opt.cache[path.join(__dirname, 'node_modules/nconf/package.json')] = { deps: [], src: '' }
required('lib/worker/harness.js', opt, (err, deps) => {
I tried to make a PR but wasn't able to get it to work... 😢
$ node
> require('package.json')
Error: Cannot find module 'package.json'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at repl:1:1
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:95:20)
I think you meant require('./package.json')
?
Yeah you're right, I will edit.
It's possible to do this in node:
Which will result in an object representing your
package.json
file. Howeverrequired
seems to blow up if you do this.Sadly, I have a dependency on nconf which does this so I can't resolve my dependencies. Do you have any recommendations on how I can work around it?