In order to have the measurements displayed of a photocell linked to an Arduino on the terminal, Iam trying to execute a node.js server. It's from a tutorial made by Adil Moujahid

I tried to follow the following:

from you terminal go to the folder where server1.js is saved, and execute node server1.js.

Yet, I was advised by this answer (the second one) not to use Node.js but rather the CMD terminal.

So despite of my lack ok knowledge of the commands of this terminal (I learned Linux) I went to this terminal, went to the directory where server1.js is(C:\Users\Antoine\Documents\Arduino\Connected Objects\sketch_jan30a) with cd and did:

Wscript.exe Automation \Framework\server1.js

Which didn't work so I tried

Wscript.exe \Framework\server1.js

Wich didn't work and sent me a windows Script error:

the error message

So I thought something was wrong with server1.js code:

var serialport = require('serialport');
var portName = '/dev/tty.usbmodem1411';
var sp = new serialport.SerialPort(portName, {
    baudRate: 9600,
    dataBits: 8,
    parity: 'none',
    stopBits: 1,
    flowControl: false,
    parser: serialport.parsers.readline("\r\n")

sp.on('data', function(input) {

Is there something wrong with portname? It's my best guess from what's written by the tutorial made by Adil Moujahid and from what is written on the message.

Can you help me either to write execute the .js file or tell me if something's wrong in my code (in this case I will try to move this question to a more appropirate forum)


The answer to your other question told you to run NPM commands outside of the node.js terminal. npm is a keyword that tells the command prompt to use a particular application to process the commands or arguments. In your case you're trying to run a js server written for node.js so rather than using npm install ... you would use probably use node server1.js (if you're trying to run it outside of the node.js terminal window, after cd'ing to the appropriate directory)

Sorry, just saw this question is old. Hopefully you got it by now and this post will help someone else just learning.


The code is fine, but it was written for a different runtime. WScript is very different from node.js (just like both are different from the "usual" web-browser environment) – for example, it does not support require() nor console. (Technically it's not even JavaScript but JScript.)

You will have to download node.js for Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.