admin管理员组

文章数量:1389758

So I'm trying to build a mand 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 mand line I get a Microsoft JScript pilation error at line 1 char 1 invalid character code 800A03F6.

Any ideas what I might be missing? Thanks :)

So I'm trying to build a mand 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 mand line I get a Microsoft JScript pilation error at line 1 char 1 invalid character code 800A03F6.

Any ideas what I might be missing? Thanks :)

Share Improve this question asked May 24, 2018 at 2:08 rycireserycirese 1992 silver badges16 bronze badges 2
  • How do you run this ? Seems like Windows Scripting Host processes your code, not Node – Marged Commented May 24, 2018 at 2:11
  • I just type test into the mand line – rycirese Commented May 24, 2018 at 2:13
Add a ment  | 

1 Answer 1

Reset to default 4

Found the information from this tutorial

npm install -g

test

Hello, world!

Did you try to install it before running it?

本文标签: javascriptJScript compilation error nodejs command line toolStack Overflow