ozgrozer / chatgpt-artifacts

Bring Claude's Artifacts feature to ChatGPT
https://thenextaitool.com
GNU General Public License v3.0
434 stars 81 forks source link

Error while previewing the html css js component #7

Closed NileshArnaiya closed 2 months ago

NileshArnaiya commented 2 months ago

Getting this error while previewing the generated code. Please can you check. I'm using GPT-35-turbo using Azure OpenAI.

 ⨯ unhandledRejection: Error: Command failed: cd /tmp/chatgpt-artifacts/6e696da4-082d-4874-b36f-5f64b4e4e022 && npm init -y && npm pkg set type=module && 
/bin/sh: 1: Syntax error: end of file unexpected

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:518:28)
    at Pipe.<anonymous> (node:net:337:12)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 2,
  killed: false,
  signal: null,
  cmd: 'cd /tmp/chatgpt-artifacts/6e696da4-082d-4874-b36f-5f64b4e4e022 && npm init -y && npm pkg set type=module && '

Prompt was "Use html,css, js to explain me circular motion"

@ozgrozer

NileshArnaiya commented 2 months ago

Also adding this screenshot here. White screen many times and the same error as above. image

Dhruvil099 commented 2 months ago

@NileshArnaiya Add the following lines const joinedCommands = commands.join(' && '); const cleanedCommands = joinedCommands.endsWith(' && ') ? joinedCommands.slice(0, -2) : joinedCommands; just below return new Promise((resolve, reject) line in server/execute.js and server/execute-react.js files and replace exec(commands.join(' && '), (err, stdout, stderr) => { with exec(cleanedCommands, (err, stdout, stderr) => { in both the files, it should work just fine.

NileshArnaiya commented 2 months ago

Thank you @Dhruvil099 works like a charm, I'll email you back with some queries. Closing this now.