Saturday 13 May 2017

Uncaught TypeError when trying to browserify a node module

I'm trying to find a way I can use this algorithm within a function on the client side. The Module is called RAKE and I'm trying to wrap it around a function so I can use it on the client side by browserifying it.

Here is the github for RAKE: https://github.com/waseem18/node-rake

try.js (compiling this) into bundle.js

var rake = require('node-rake')
// Will produce keywords
function rake_it(text){

    return rake.generate(text)
}

console.log(rake_it("LDA stands for Latent Dirichlet Allocation"))

Ideally I want to use this function when a user types inside of a form and generate the keywords from the text.

So I compile try.js doing browserify try.js -o bundle.js

I put bundle.js into an index.html for testing but get this error inside of the console window.

bundle.js:27 Uncaught TypeError: fs.readFileSync is not a function
    at Rake.getStopWordsFromFile (bundle.js:27)
    at Rake.buildRegex (bundle.js:33)
    at new Rake (bundle.js:23)
    at Object.generate (bundle.js:9)
    at rake_it (bundle.js:145)
    at Object.3.fs (bundle.js:148)
    at s (bundle.js:1)
    at e (bundle.js:1)
    at bundle.js:1



via Kenny Ho

No comments:

Post a Comment