4

I am trying to play around with the natural module in Node.JS. I wrote a simple program that takes an input from the browser and uses the Bayes' Classifier to classify it. However, at run time, I get the following error:

/home/hadoop/cloud_major/testing/node_modules/natural/node_modules/apparatus/lib/apparatus/classifier/bayes_classifier.js:95
 classifier.__proto__ = BayesClassifier.prototype;
                      ^
TypeError: Cannot set property '__proto__' of undefined
at Function.restore (/home/hadoop/cloud_major/testing/node_modules/natural/node_modules/apparatus/lib/apparatus/classifier/bayes_classifier.js:95:27)
at restore (/home/hadoop/cloud_major/testing/node_modules/natural/lib/natural/classifiers/bayes_classifier.js:37:54)
at /home/hadoop/cloud_major/testing/node_modules/natural/lib/natural/classifiers/bayes_classifier.js:44:23
at /home/hadoop/cloud_major/testing/node_modules/natural/lib/natural/classifiers/classifier.js:114:13
at fs.readFile (fs.js:176:14)
at Object.oncomplete (fs.js:297:15)

Now, for research, I went through the following thread by someone who had a similar problem in another Node.JS module: https://github.com/andris9/mailcomposer/issues/6 I followed the solution of uninstalling and reinstalling natural, with no help. I also found: http://tommytcchan.blogspot.in/2012_07_01_archive.html I used npm ls to get:

├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]

Then, I went through: Find the version of an installed npm package and got the following output:

├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]

i.e. I think that local version of the installed packages matches the dependencies required.Has anyone else used this package, and managed to debug this error?

Many thanks in advance!

Community
  • 1
  • 1
shikharraje
  • 127
  • 1
  • 17

1 Answers1

0

Just a guess, but I think that it is due to improper initialization.

TypeError: Cannot set property '__proto__' of undefined

I get similar errors when I try to use properties of objects that I forget to initialize first. Guessing from the error you may not have defined or initialized classifier, making it undefined. you You can't set or use properties on undefined.

Here are a similar posts :

  1. JavaScript - cannot set property of undefined and
  2. Cannot Set Property ... of undefined --- bizarre
Community
  • 1
  • 1
user568109
  • 47,225
  • 17
  • 99
  • 123