Invalid or unexpected token with JavaScript set up to use nodejs

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.
This topic is 5 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
paul.obrien@acculink.com
Posts: 2
Last visit: Mon May 18, 2020 9:54 am

Invalid or unexpected token with JavaScript set up to use nodejs

Post by paul.obrien@acculink.com »

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 7608 times
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 12:38 am
Answers: 19
Been upvoted: 37 times

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

Post by Alexander Riedel »

What is the encoding of your source file?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 12:38 am
Answers: 19
Been upvoted: 37 times

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

Post by Alexander Riedel »

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 7589 times
I am not sure what that is but it seems NodeJS related.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 12:38 am
Answers: 19
Been upvoted: 37 times

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

Post by Alexander Riedel »

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 7587 times
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
paul.obrien@acculink.com
Posts: 2
Last visit: Mon May 18, 2020 9:54 am

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

Post by paul.obrien@acculink.com »

That worked - thanks so much for your help!
This topic is 5 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.