Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rclnodejs cannot be used with React #926

Open
JackHaleGreenfield opened this issue Aug 10, 2023 · 1 comment
Open

rclnodejs cannot be used with React #926

JackHaleGreenfield opened this issue Aug 10, 2023 · 1 comment
Labels

Comments

@JackHaleGreenfield
Copy link

Description
rclnodejs generates a ReferenceError in the console log of ReactJS apps trying to use it. This error occurs simply by trying to call the init() function of the rclnodejs package (as per the typescript example in this project's README). Although the error message says is referencing the "process" package, manually installing "process" via npm does not resolve this error. The same behavior is seen with both Foxy and Humble versions of ROS2.

  • Library Version: 0.22.2
  • ROS Version: Foxy or Humble
  • Platform / OS: Ubuntu 22.04.3 LTS (Jammy Jellyfish)
  • NodeJS Version: 16.20.1
  • npm Version: 8.19.4

Steps To Reproduce

  1. npx create-remix
  2. source /opt/ros/foxy/setup.bash
  3. cd my-remix-app && npm install rclnodejs
  4. Modify app/routes/_index.tsx so that
    • import * as rclnodejs from 'rclnodejs'; is located at the top of the file
    • import { useEffect } from "react"; is located at the top of the file
    • useEffect(() => { rclnodejs.init().then(() => { console.log("init"); }); }, []); is located inside the Index() function
  5. npm run dev
  6. Open web browser and navigate to localhost:3000
  7. Open the browser's console log and refresh the page

Expected Behavior
Console Log contains the following log message:

init

Actual Behavior
Console Log contains the following error:

Uncaught ReferenceError: process is not defined
js bindings.js:23
__require2 chunk-PZDJHGND.js:18
js clock.js:17
__require2 chunk-PZDJHGND.js:18
js index.js:19
__require2 chunk-PZDJHGND.js:18
_index.tsx:23

@minggangw
Copy link
Member

@JackHaleGreenfield thanks for reporting this issue, the rclnodejs doesn't support web browser and it needs node.js, if you want to use web, you suggest you could leverage Electron. You can search the old issues that are relevant to Electron to see how to set it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants