Skip to main content
February 20, 2024
Solved

LucidChart with React

  • February 20, 2024
  • 14 replies
  • 1599 views

Hello,

I am following the steps from the LucidChart Developer Docs “Using web frameworks | Using React: found here.

https://developer.lucid.co/guides/?_gl=1*mhld9f*_ga*MTA5NzkzMTU0NC4xNjk2NTE0NTk1*_ga_MPV5H3XMB5*MTcwODQ2MDk4My4xLjAuMTcwODQ2MDk4My42MC4wLjA.*_gcl_au*MTUzOTY2NTcwOS4xNzA4NDYwOTg1#using-react

I created an empty directory:  C:\ReactLucidTest

Following step 1, i created a package called “reacttest”

I also created an editor extension called “with-cool-ui’.

In step 2, I created the react app called rightpanel inside of with-cool-ui extension.  npm start successfully launched my browser and showed the CRA application.

In step 3, I opened up "C:\ReactLucidTest\reacttest\editorextensions\with-cool-ui\webpack.config.js" in notepad and replaced it with the code from the Developer Docs in step 3.

In step 4, I opened up "C:\ReactLucidTest\reacttest\editorextensions\with-cool-ui\src\extension.ts" and replaced the contents with the code found in step 4 on Developer Docs in step 4.

In step 5, I am getting an error when running the command “npx lucid-package test-editor-extension with-cool-ui”. The server from step 2 is still running.

 

Here is the exact error:

Executing onWatchRun build scripts

stderr error mkdir -p ../../public/rightpanel &&curl http://localhost:3000 | sed -E "s/(src|href)=\"/\\1=\"http:\/\/localhost:3000/gi" > ../../public/rightpanel/index.html: The syntax of the command is incorrect.

 

Listening at http://localhost:9900/extension.js

Listening at http://localhost:9901/shapeLibraries

Found npm start script in C:\ReactLucidTest\reacttest\editorextensions\with-cool-ui\rightpanel.

node:events:491

      throw er; // Unhandled 'error' event

      ^

 

Error: spawn npm ENOENT

    at ChildProcess._handle.onexit (node:internal/child_process:283:19)

    at onErrorNT (node:internal/child_process:476:16)

    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Emitted 'error' event on ChildProcess instance at:

    at ChildProcess._handle.onexit (node:internal/child_process:289:12)

    at onErrorNT (node:internal/child_process:476:16)

    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {

  errno: -4058,

  code: 'ENOENT',

  syscall: 'spawn npm',

  path: 'npm',

  spawnargs: [ 'start' ]”

 

Anyone able to help?  Maybe in step 3 or 4, the code on the Developer Docs that I pasted into those 2 files is incorrect?  Can anyone maybe try to do the steps outlined in the Developer Docs and see if they can get it working?

Thanks, Dan

Best answer by ablackburn

Hey Dan,

 

We can absolutely meet with you to help get things unblocked. I’ll reach out via email  to schedule.

 

Alex

Comments

May 22, 2024

@ablackburn  What was the solution if you do not mind sharing

Richard Udell
Lucid support team
May 29, 2024

Hi @rayvega, my name is Richard from the Technical Support team here at Lucid. This is a great question! Thanks for your patience with our reply. I checked-in with the devs this morning and unfortunately it’s not clear exactly what the solution was. I learned that, at a higher level, the solution came from getting the open source example up and running.  The example and setup instructions are stored in our sample-lucid-extensions GitHub repo.

@PromitaDan Do you have any more insights here into how you and @ablackburn solved this issue?

June 29, 2024

Hello!

I tried to create the package from scratch again today hoping that the issue was fixed. Unfortunately, it appears that developing a LucidChart package and editor extension on a windows machine still does not work.  I still receive the same error. 

Are there any known workarounds for this issue?  I cant be the only one using a windows development machine.

Thanks, Dan

 

Richard Udell
Lucid support team
July 2, 2024

Hey @PromitaDan, I’m glad to hear that you met with Alex this morning to get this issue resolved. Just wanted to summarize your call with Alex for the thread:

  1. File Generation Issue on Windows:

    • Windows wasn’t generating a required file correctly. You and Alex manually copy-pasted the contents into your /public/rightpanel folder, which got the Lucid extension properly communicating with the React app.
  2. npm Start Script Issue:

    • The CLI was detecting an npm start script and trying to run it, which caused a bug. You resolved this by:
      • Deleting an erroneously created folder in your extension that had a package.json with a problematic start script.
      • Removing the start script from the package.json of your React app.
      • Running the React app manually using npx react-scripts start. This step might not have been necessary but helped in troubleshooting.

Thanks for your patience, and let us know if you need any more help!