mkdirp package: https://www.npmjs.com/package/mkdirp 

安装:npm i mkdirp --save 

源码: 

const mkdirp = require('mkdirp');
var path='./xxx';
mkdirp(path, function(err){
    if(err){
        console.log(err);
        return;
    }
    else{
        console.log('pow!');
    }
})
报错:
异常:mkdirp -- "TypeError: invalid options argument"

原因:(版本更新导致)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

解决:(参考官方package的使用说明)

mkdirp(path).catch(err =>{console.log(err)}).then(p => console.log(`made dir staring with ${p}`))
 
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-03-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-01-13
相关资源
相似解决方案