Rohan Khajuria
Rohan Khajuria

Reputation: 716

Loading Node.js Module using Browserify

I am using Browserify (http://browserify.org/) to load a module in JavaScript. I keep getting the following error:

error

I have no idea why this is happening. I have a "package.json" file in a directory called "wordnet-develop", which is located in the same location as the JavaScript file.

Originally I thought that there might be a path problem. However, I did the same exact thing but with a test.js file, and it worked. So, I think that there may be something wrong with using package.json.

The beginning of the package.json file:

package.json

The beginning of my JavaScript file:

popup.js

The directory containing the javascript file: directory 1

The directory (seen above as "wordnet-develop")containing the package.json file: directory 2

UPDATE

I replaced var WordNet = require('./wordnet-develop/node-wordnet'); with var WordNet = require('./wordnet-develop/lib/wordnet'); as suggested by klugjo.

It may have worked, but now I am getting a new error message:

another error :(

This happened again but with 'async' module missing. I checked lib/wordnet, and it included requirements for bluebird and async, so that's probably the error source.

However, I now have no idea what to do. I'm new to node.js and modules, so I'm unfamiliar with solutions. Am I supposed to parse all of the code and find all the required modules online? Shouldn't they have been included in the module? Is the problem that I'm trying to use a node.js module in vanilla JavaScript?

Upvotes: 1

Views: 167

Answers (1)

klugjo
klugjo

Reputation: 20875

I don't think what you are trying to do is supported: you have to link directly to the entry javascript file of the node-wordnet library.

Replace

var WordNet = require('./wordnet-develop/node-wordnet');

With

var WordNet = require('./wordnet-develop/lib/wordnet');

Upvotes: 1

Related Questions