Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Syntax error line 1 character 1

Juice3d

New Coder
Hi ,
I've never really coded before so bear with me , im trying to run this javascript

const { Chatbot } = require('tchatgpt');
const config = require('./config.json');
const chatbot = new Chatbot(config);
chatbot.refresh_session().then(() => {
chatbot.get_chat_response('Hello').then(console.log);
});

I've coppied it directly from the github where the code is from , however Im getting this error when i try to run it , all the necessary files are in the correct location

ERROR

Windows script host
Line:1
Char:1
Rrror: syntax error
code: 800A03EA
source: microsoft jscript compilation error

am i missing a library or is something missing from the code ? i asked chatgpt and it said i could try changing the 1st line to const Chatbot = require('tchatgpt').Chatbot;
however this led to the same error code .
Anyone know whats wrong ?

Thanks for the help
 
Please use code tags for your code and Java <> Javascript ;)

This might be issue with ES6 vs. ES5. If you rename the suffix of your file from .js to .cjs then will it help?

Also more information would help. Are you trying to run this with browser or with nodejs or something else?
 
This is valid code ! The error is what you get for trying to execute a Node.js script with the Windows Script host.
I think you just specified the file name on the command line, or perhaps clicked it in the Windows explorer ? I get the same error when I do that.

You need to download and install Node.js and let node run it :
node myfile.js
You also need to provide the required config.json file.
 
Back
Top Bottom