node.js官网小例子运行不起来
我的 node 版本是 5.0.0
下面是从官网 https://nodejs.org/api/querystring.html 中摘抄下搂的代码:
var querystring = require('querystring')
var queryString = querystring.stringify({ w: '中文', foo: 'bar' }, null, null, {encodeURIComponent: gbkEncodeURIComponent})
console.log(queryString)
运行之后,报错信息如下:
WeiHeLi:node weiheli$ node 001.js
/Users/weiheli/code/node/001.js:3
var queryString = querystring.stringify({ w: '中文', foo: 'bar' }, null, null, {encodeURIComponent: gbkEncodeURIComponent})
^
ReferenceError: gbkEncodeURIComponent is not defined
at Object.<anonymous> (/Users/weiheli/code/node/001.js:3:99)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:136:18)
at node.js:972:3
哪里错了?