Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JScript compilation error nodejs command line tool

So I'm trying to build a command line tool using node.js but am running into problems trying to run the tool. Here's the simple code that I have.

src/main.js

#!/usr/bin/env node
'use strict';

(function main() {
    console.log('Hello World!');
})();

and in my packages.json I have this added

"bin": {
    "test": "./src/main.js"
 }

But when I try and execute test from the command line I get a Microsoft JScript compilation error at line 1 char 1 invalid character code 800A03F6.

Any ideas what I might be missing? Thanks :)

like image 564
rycirese Avatar asked Mar 30 '26 00:03

rycirese


1 Answers

Found the information from this tutorial

npm install -g

test

Hello, world!

Did you try to install it before running it?

like image 189
Isaac Avatar answered Apr 01 '26 10:04

Isaac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!