Ponsietta
Ponsietta

Reputation: 319

Problem using .load function in Node Repl

I am running Nodejs and trying to load a script in repl using: .load transformscript.js

The first two lines in transformscript.js are as below: .load rdfMapping.js .load rdfVocab.js

The problem is that I am getting the error 'SyntaxError: Unexpected token .' on the first line. Does someone have any idea why this might be, as I do not have much experience with Node and repl.

Upvotes: 0

Views: 361

Answers (1)

vsemozhebuty
vsemozhebuty

Reputation: 13812

You can only use .load path_to_the_module command in the REPL console. To load modules in a file script, you need to use require('path_to_the_module').

So the first lines in the transformscript.js should be:

require('./rdfMapping.js');
require('./rdfVocab.js');

Upvotes: 2

Related Questions