0

I have successfully produced a parser.js file using the peg.js online tool. I have linked it to my html file using:

    <script src="parser.js"></script>

I intended to run parser.parse(txt) from my script however I get ReferenceError: module is not defined from the first line of parser.js which is module.exports =

Having looked at documentation and I think this is connected with having not installed node.js although I'm running my test using REPL which I thought came with node.js installed anyway.

Is there anyway of getting this running by importing js modules and not having to install node.js and if so how?

1 Answers1

0

I can answer my own question here if it is of any use to anyone:

I can change the opening line of the parser.js from module.exports to var myparser =.

Hence I can now run myparser.parse(txt) successfully. No need for node.js or the imports statement.