Reputation: 2000
I have been trying to run some node js files. I have checked the files and they seem to have no syntax errors whatsoever. However, upon running the file on the node js command line i get this error
node first.js
^^^^^
SyntaxError: Unexpected identifier
Lately, I have also been unable to run my apache web server from XAMPP. Could this be a port assignee error. Or is it something else. I have also, checked the directory of the file and it checks out
Some help would be greatly appreciate
Upvotes: 0
Views: 1278
Reputation: 7413
When you're inside node's CLI, you can run JS or rather node supported instructions. Unfortunately, there is no global variable or keyword with name "node". If you want to run "first.js", you'll have to come out from node's cli and then run the command.
Upvotes: 1
Reputation: 4113
You can't run file with node first.js
inside file js
undefined
If you want run first.js
file, you can include it with require
let first = require('first);
but this way run it once (first time call it), you can use method inside first.js
with export
(or module.exports
) of first.js
.
But you just want call and run first.js
, you can use child_process.
Upvotes: 0