日常记录

https://lequ7.com/2019/02/21/richang/ke-xue-shang-wang-ss-fan-qiang-just-my-socks/

image


javascript

console.log("hello world")

python

print("hello world")

shell

echo "hello world"

ruby

puts "Hello World!"

sindresorhus 大神

https://github.com/sindresorhus

Run AppleScript and get the result run-applescript

A better child_process execa

未来的测试运行器 avajs


阮一峰 大神

JavaScript 语言入门教程https://github.com/ruanyf/jstutorial

ECMA 6入门https://github.com/ruanyf/es6tutorial

全栈工程师培训材料https://github.com/ruanyf/jstraining


npm

puppeteer

doc : https://zhaoqize.github.io/puppeteer-api-zh_CN


cheerio

doc : https://cheerio.js.org/


shelljs

doc : http://documentup.com/shelljs/shelljs


commander

doc : https://github.com/tj/commander.js


sprintf-js

doc : https://github.com/alexei/sprintf.js


sleep

doc : https://www.npmjs.com/package/sleep


request

doc : https://github.com/request/request


request-progress 如果想实现终端进度条, 还是自己写监听吧

doc : https://github.com/IndigoUnited/node-request-progress


progress 终端进度条

doc : https://github.com/visionmedia/node-progress


nanoid 生成随机字符串

doc : https://github.com/ai/nanoid


mongoose mongodb封装

doc : https://mongoosejs.com/

https://mongoose.shujuwajue.com/


gm GraphicsMagick for node.js

doc : http://aheckmann.github.io/gm/


glob

doc : https://github.com/isaacs/node-glob


concurrently 服务器 & 客户端 同时启动

doc : https://www.npmjs.com/package/concurrently


react-transition-group

doc : https://reactcommunity.org/react-transition-group/


tunnel node-tunnel - HTTP/HTTPS Agents for tunneling proxies

doc : https://github.com/koichik/node-tunnel


path-to-regexp path-to-regexp

doc : https://github.com/pillarjs/path-to-regexp


node-schedule node-schedule

doc : https://github.com/node-schedule/node-schedule


crypto-js crypto-js AES DES 加密 解密

doc : https://github.com/brix/crypto-js


Gitbook错误"cb.apply is not a function"的解决办法

Gitbook是个挺好用的Node.js应用,最近在用它翻译一本书,可以用Markdown编译,挺简洁的,网络发布也很不错。然鹅,着实遇到了一些bug,翻了代码才解决,希望给后面一样踩了坑的小伙伴一点帮助T^T

这个错误是这样的:

/usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:299
      if (cb) cb.apply(this, arguments)
                 ^
TypeError: cb.apply is not a function
    at /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:299:18
这个错误是在Generate的时候发生的,我也不知道这个cb.apply是干嘛的,我以前也没碰上,可能是最近用hexo之前升级了Node.js……吧,不管那么多,顺藤摸代码,按错误提示的路径找到polyfills.js(这个路径在你的电脑上有可能是隐藏的,总之显示隐藏文件就能看到),打开,看到第299行这里,发现这里写了个函数statFix():

function statFix (orig) {
    if (!orig) return orig
    // Older versions of Node erroneously returned signed integers for
    // uid + gid.
    return function (target, options, cb) {
      if (typeof options === 'function') {
        cb = options
        options = null
      }
      function callback (er, stats) {
        if (stats) {
          if (stats.uid < 0) stats.uid += 0x100000000
          if (stats.gid < 0) stats.gid += 0x100000000
        }
        if (cb) cb.apply(this, arguments)
      }
      return options ? orig.call(fs, target, options, callback)
        : orig.call(fs, target, callback)
    }
  }
在里面定义了一个`callback`,用到了`cb.apply`:

if (cb) cb.apply(this, arguments)
搜索statFix()函数,发现在polyfills.js的第65行起:

fs.stat = statFix(fs.stat)
fs.fstat = statFix(fs.fstat)
fs.lstat = statFix(fs.lstat)
emm,看statFix()里的注释信息

// Older versions of Node erroneously returned signed integers for
// uid + gid.
似乎是为了解决旧版本返回uid+gid时候的数据类型的问题,然而我是更新了之后才出的问题 ,所以这个函数应该用不上了。

所以,将65行起的三行都注释掉:

// fs.stat = statFix(fs.stat)
// fs.fstat = statFix(fs.fstat)
// fs.lstat = statFix(fs.lstat)
搞定!再次运行Gitbook生成作品,没问题了!✿✿ヽ(°▽°)ノ✿

results matching ""

    No results matching ""