i am attempting to use elementtree in my node js server however the following message is genearted on server startup
Cannot find module 'sax'
i had to install elementree from zip, what have i done wrong?
these are my rquire statements
var cache = require('./node_modules/node-cache');
var elementTree = require('./node_modules/node-elementtree');
this is my folder structure
module\node_modules\node-cache
module\node_modules\node-elementtree
my server js script resides in \module
The problem is because you are not using npm for installing your node-elementtree module
This is the package.json
of node-elementtree. and it is clearly mentioned that there is a dependency on sax 0.3.5
"dependencies" : {
"sax": "0.3.5"
}
Incase if you had done npm install
it would have resolved your dependency constraints.
Inside your node-elementtree module it uses sax here and your require didn't resolve to a proper module. Hence the error. Incase you can't use npm then install sax too using zip if possible but it may increase your dependency list once again as the above. So, Try resolving npm issue
Also you don't need to use
var cache = require('./node_modules/node-cache');
var elementTree = require('./node_modules/node-elementtree');
in your code
var cache = require('node-cache');
var elementTree = require('node-elementtree');
the above would do. Node automatically locates the module from ./node_modules directory and even from many more places