Invalid or unexpected token with JavaScript set up to use nodejs

Support for all customers who have purchased a PrimalScript product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
paul.obrien@acculink.com
Posts: 2
Joined: Thu Mar 20, 2014 10:08 am

Invalid or unexpected token with JavaScript set up to use nodejs

Post by paul.obrien@acculink.com » Tue Dec 18, 2018 2:41 pm

Product, version and build: PrimalScript Version 7.4.118 64 bit
Operating system: Windows 10 Pro 64 bit

I've set up JavaScript to use node.js. When I try and run just a simple program such as...

Code: Select all

console.log('Hello world!');
I get the following error in the output window...

D:\How Tos\nodejs\myHello.js:1
(function (exports, require, module, __filename, __dirname) { ��c
^

SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Execution time: < 1 second
Exit code: 1 , 0001h



I'm not sure where those characters after the "{" are coming from. Here's my settings for JavaScript...

javascript setup.png
javascript setup.png (22.01 KiB) Viewed 557 times

User avatar
Alexander Riedel
Posts: 6864
Joined: Tue May 29, 2007 4:43 pm

Re: Invalid or unexpected token with JavaScript set up to use nodejs

Post by Alexander Riedel » Tue Dec 18, 2018 8:59 pm

What is the encoding of your source file?
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Alexander Riedel
Posts: 6864
Joined: Tue May 29, 2007 4:43 pm

Re: Invalid or unexpected token with JavaScript set up to use nodejs

Post by Alexander Riedel » Tue Dec 18, 2018 10:51 pm

The good news is that I get the same result. I also get the same result just running any JS file in a console.
2018-12-18_21-48-55.png
2018-12-18_21-48-55.png (171.45 KiB) Viewed 538 times
I am not sure what that is but it seems NodeJS related.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Alexander Riedel
Posts: 6864
Joined: Tue May 29, 2007 4:43 pm

Re: Invalid or unexpected token with JavaScript set up to use nodejs

Post by Alexander Riedel » Tue Dec 18, 2018 10:55 pm

Ah, NodeJS cannot handle unicode files. Change the file encoding to UTF-8 and it will be fine.
2018-12-18_21-56-21.png
2018-12-18_21-56-21.png (125.04 KiB) Viewed 536 times
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
paul.obrien@acculink.com
Posts: 2
Joined: Thu Mar 20, 2014 10:08 am

Re: Invalid or unexpected token with JavaScript set up to use nodejs

Post by paul.obrien@acculink.com » Wed Dec 19, 2018 9:04 am

That worked - thanks so much for your help!