olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.96k stars 548 forks source link

make server exception for the latest Node.js (v0.12.0) #140

Closed weixsong closed 9 years ago

weixsong commented 9 years ago

I'm using the latest Node.js (v0.12.0) to run the unit test cases by make server, but it report an exception, then I changed to Node.js (v0.10.0), when using make server, it still report an exception.

The following is detailed information.

  1. When using Node.js v0.10.0: make server run, but when open the link by browser it will report an excepiton.

songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ node -v v0.10.0 songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make test Starting test server at http://localhost:32423 Took 74ms to run 301 tests. 301 passed, 0 failed. songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make server /usr/local/bin/node server.js 3000

Server listening on 3000

GET /test /home/songwei/WeiSONG/work/lunr.js/lunr.js/server.js:32 exists(path, function(exists){ ^ TypeError: undefined is not a function at Server. (/home/songwei/WeiSONG/work/lunr.js/lunr.js/server.js:32:3) at Server.emit (events.js:110:17) at HTTPParser.parserOnIncoming as onIncoming at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23) at Socket.socketOnData (_http_server.js:343:22) at Socket.emit (events.js:107:17) at readableAddChunk (_stream_readable.js:163:16) at Socket.Readable.push (_stream_readable.js:126:10) at TCP.onread (net.js:529:20) make: *\ [server] Error 1

  1. Then I changed to Node.js v0.12.0, make server runs, but when open the link in browser, it report an exception: songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ nvm use system Now using system version of node: v0.12.0. songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ node -v v0.12.0 songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make test Starting test server at http://localhost:32423 Took 74ms to run 301 tests. 301 passed, 0 failed. songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make server /usr/local/bin/node server.js 3000

    Server listening on 3000

    GET /test /home/songwei/WeiSONG/work/lunr.js/lunr.js/server.js:32 exists(path, function(exists){ ^ TypeError: undefined is not a function at Server. (/home/songwei/WeiSONG/work/lunr.js/lunr.js/server.js:32:3) at Server.emit (events.js:110:17) at HTTPParser.parserOnIncoming as onIncoming at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23) at Socket.socketOnData (_http_server.js:343:22) at Socket.emit (events.js:107:17) at readableAddChunk (_stream_readable.js:163:16) at Socket.Readable.push (_stream_readable.js:126:10) at TCP.onread (net.js:529:20) make: *\ [server] Error 1

Then, I looked the documents of Node.js, it seems that from some specified version, 'exists' function is remove from 'path' module, and moved to 'file' module. Then, I modified the code in "server.js", it works for Node.js v0.12.0: songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ node -v v0.12.0 songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make server /usr/local/bin/node server.js 3000

Server listening on 3000

GET /test GET /test/env/jquery.js GET /test/env/augment.min.js GET /test/env/qunit.js GET /test/env/qunit.css GET /lib/lunr.js GET /lib/utils.js GET /lib/tokenizer.js GET /lib/pipeline.js GET /lib/vector.js GET /lib/sorted_set.js GET /lib/event_emitter.js .....

And, it alsl work in Node.js v0.10.0:

songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ nvm use 0.10.0 Now using node v0.10.0 songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ node -v v0.10.0 songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make test Starting test server at http://localhost:32423 Took 74ms to run 301 tests. 301 passed, 0 failed. songwei@songwei-ThinkPad-T410:~/WeiSONG/work/lunr.js/lunr.js$ make server /usr/local/bin/node server.js 3000

Server listening on 3000

GET /test GET /test/env/jquery.js GET /test/env/augment.min.js GET /test/env/qunit.js GET /test/env/qunit.css GET /lib/lunr.js GET /lib/utils.js GET /lib/tokenizer.js

olivernn commented 9 years ago

fixed and released in 0.5.8, let me know if there are any further issues.