CH341SER error when trying to run LED

I get an error when I upload the JS file to the CH341SER using VSC with Terminal.

Here is the error:

internal/modules/cjs/loader.js:965
  throw err;
  ^

Error: Cannot find module 'C:\Users\HP\run.js'
←[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:838:27)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

Here is the code:

const five = require('johnny-five');         
const board = new five.Board();              
 
board.on('ready', () => {                    
  const led = new five.Led(2);              
  led.blink(500);                           
});

The Arduino IDE works fine.

Here is the code:

#define OUR_LED 2

void setup() {

pinMode(OUR_LED, OUTPUT);
}
void loop() {
digitalWrite(OUR_LED, HIGH);
delay(1000);
digitalWrite(OUR_LED, LOW);
delay(1000);
}

Setup:

node-v13.14.0-x64 +
johnny-five package
Windows 7

This is the first time I've tried anything outside of the Arduino IDE. So, I don't know if the problem is the code, the Chinese microcontroller or the setup.

How can I fix this? Any help is much appreciated!

I tried renaming my file to test.js and ran the command node test.js , However, I still get this error when I run it:

Error: Cannot find module 'johnny-five'
Require stack:
- C:\Users\HP\Documents\GitHub\NODE\test.js
←[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:838:27)←[39m
←[90m    at Module.require (internal/modules/cjs/loader.js:1022:19)←[39m
←[90m    at require (internal/modules/cjs/helpers.js:72:18)←[39m
    at Object.<anonymous> (C:\Users\HP\Documents\GitHub\NODE\test.js:1:14)
←[90m    at Module._compile (internal/modules/cjs/loader.js:1118:30)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:982:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:875:14)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: [ ←[32m'C:\\Users\\HP\\Documents\\GitHub\\NODE\\test.js'←[39m ]
}

It says it can't find the johnny-five module but i've already installed it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.