Fatal error in …/deps/v8/src/handles.h, line 48
CHECK(location_ != NULL) failed
==== C stack trace ===============================
1: V8_Fatal 2: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int) 3: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding) 4: void node::Buffer::StringSlice<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) 5: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) 6: ?? 7: ??
使用 edu_school_dict = fs.readFileSync(file_path, “utf8”);或者edu_school_dict = require(file_path);加载直接报上面的错
我这边需求需要分析大数据文件 非日志文件 想用nodejs处理 问大家是否有好的方法
[icsongzhi@appBI42 appnode]$ node server.js module.js:338 throw err; ^ Error: Cannot find module ‘debug’ at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/opt/userhome/icsongzhi/server/ifchange_mobile_server/appnode/node_modules/lei-stream/lib/utils.js:7:19) at Module._compile (module.js:460:26) at Object.Module._extensions…js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) 好像util里面的debug模块没有 可以给个可运行的吗
@leizongmin 用你的模块报错了-_-
opt/userhome/icsongzhi/server/ifchange_mobile_server/appnode/node_modules/lei-stream/lib/readline.js:0
RangeError: Invalid string length at ReadLineStream._onData (/opt/userhome/icsongzhi/server/ifchange_mobile_server/appnode/node_modules/lei-stream/lib/readline.js:62:17) at ReadStream.<anonymous> (/opt/userhome/icsongzhi/server/ifchange_mobile_server/appnode/node_modules/lei-stream/lib/readline.js:48:10) at ReadStream.emit (events.js:107:17) at readableAddChunk (_stream_readable.js:163:16) at ReadStream.Readable.push (_stream_readable.js:126:10) at onread (fs.js:1679:12) at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)
我就一个600多m的一行大json数据
果然 在使用这种方式 var file_path = writeDir + generate_file_map[‘edu_school_dict’]; // var file_path = writeDir + "test.json";
// readLineStream第一个参数为ReadStream实例,也可以为文件名 var s = readLine(fs.createReadStream(file_path), { // 换行符,默认\n newline: '\n’, // 是否自动读取下一行,默认false autoNext: false, // 编码器,可以为函数或字符串(内置编码器:json,base64),默认null encoding: function (data) { return JSON.parse(data); } });
// 读取到一行数据时触发data事件 s.on('data’, function (data) { console.log(data[“major”][13884256]); s.next(); });
// 流结束时触发end事件 s.on('end’, function () { // console.log(‘end’); cb(null, null); });
也是报错
RangeError: Invalid string length
at ReadLineStream._onData (/opt/userhome/icsongzhi/server/ifchange_mobile_server/appnode/node_modules/lei-stream/lib/readline.js:62:17)
at ReadStream.<anonymous> (/opt/userhome/icsongzhi/server/ifchange_mobile_server/appnode/node_modules/lei-stream/lib/readline.js:48:10)
at ReadStream.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at ReadStream.Readable.push (_stream_readable.js:126:10)
at onread (fs.js:1679:12)
at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)