Getting "TypeError: invalid options argument" after upgrade
logidelic opened this issue · 2 comments
I recently upgraded my server from Node 10 -> 12 and in the process upgraded to the latest version of this npm module. Code which had been working fine for years, started throwing an exception. Specifically:
const mkdirp = require('mkdirp');
mkdirp(someValidPathString, function (err) {
...
});
Started throwing:
{"message":"invalid options argument","name":"TypeError","stack":"TypeError: invalid options argument
at optsArg (/home/ubuntu/dev/myproj/node/node_modules/mkdirp/lib/opts-arg.js:13:11)
at mkdirp (/home/ubuntu/dev/myproj/node/node_modules/mkdirp/index.js:11:10)
at myfunc (/home/ubuntu/dev/myproj/node/myproj.js:1000:13)
No idea what I could be doing wrong here. I gave up and switched to the native fs.mkdir(recurisive).
mkdirp@1.0.0
no longer supports callbacks and instead uses promises. If you have older code that uses the callback way and don't want to migrate, use mkdirp@0.5.1
It's a better idea to migrate, but it's understandable that migrating code from 4 years ago isn't worth the effort sometimes.
https://github.com/isaacs/node-mkdirp#choosing-a-recursive-mkdir-implementation
Semver major version bumps typically indicate breaking changes, where you must change your code in order to accept the update. This is one such example.