node-bunyan
node-bunyan copied to clipboard
Missing 'mv' module due to how it is required (Meteor)
Hi,
We use Bunyan in an NPM module that gets imported into a few Meteor projects. I'm trying to use rotating files, but have an issue with mv
AssertionError: "rotating-file" stream type is not supported: missing "mv" module at Logger.addStream (node_modules/blinklog/node_modules/bunyan/lib/bunyan.js:605:1) at node_modules/blinklog/node_modules/bunyan/lib/bunyan.js:468:1 at Array.forEach (native) at new Logger (node_modules/blinklog/node_modules/bunyan/lib/bunyan.js:467:1) at Function.createLogger (node_modules/blinklog/node_modules/bunyan/lib/bunyan.js:1616:1) at createInstance (node_modules/blinklog/lib/blinklog.js:61:1) at Object.getInstance (node_modules/blinklog/lib/blinklog.js:81:1) at meteorInstall.node_modules.meteor.blinkaccountwrapper.blinkgoogle.js (packages/blinkaccountwrapper/blinkgoogle.js:5:27) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:316:1) at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:211:1)
mv exists in the top level of the node_modules folder in our NPM package, blinklog, alongside bunyan.
This is resolved by using var mv = require('mv'); instead of var mv = require('mv' + ''); in lib/bunyan.js
Could anybody give me some advice on how to sort this in a more permanent way?
Facing the same issue
This issue is still present with version 1.8.12. My platform is Debian Linux, if that matters.
node-bunyan does not seem to be actively maintained anymore.
This is also problematic when bundling a NodeJS app with Parcel or similar other bundlers.
@trentm is there any reasons why the import of "mv" is dynamic and you guys add a + '' in the require statement ?
If there's no reasons, would it be possible to make this statement static like suggested at the top of this discussion ?
Thanks
According to https://github.com/trentm/node-bunyan/commit/414f33563d52d6ceae558936a2eb111cc8b9ab66 it is to prevent that browsery detects the package name.
But I guess there are better solutions as this breaks many setups.
What I can suggest: install patch-package, do the change in the node_modules/bunyan/lib/bunyan.js file, run patch-package to generate a patch file, commit and apply it in your CI.