RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/humble/Concepts/Basic/About-Client-Libraries.html?highlight=rclnodejs#community-maintained
Apache License 2.0
311 stars 70 forks source link

Run rclnodejs in Dockerfile #887

Closed gildas04 closed 1 year ago

gildas04 commented 1 year ago

HI, i am trying to install rclnodejs with dockerfile and I am facing compiling errors. To get more info I used "npm install --loglevel verbose" on this setup:

Library Version: 0.21.4 ROS Version: foxy and this is the output:

Step 35/40 : RUN npm update ---> Running in 966338a5733d npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.

@rclnodejs/ref-napi@4.0.0 install /root/node_modules/@rclnodejs/ref-napi node-gyp rebuild

make: Entering directory '/root/node_modules/@rclnodejs/ref-napi/build' CC(target) Release/obj.target/nothing/../../node-addon-api/nothing.o AR(target) Release/obj.target/../../node-addon-api/nothing.a COPY Release/nothing.a CXX(target) Release/obj.target/binding/src/binding.o SOLINK_MODULE(target) Release/obj.target/binding.node COPY Release/binding.node make: Leaving directory '/root/node_modules/@rclnodejs/ref-napi/build'

int64-napi@1.0.2 install /root/node_modules/int64-napi node-gyp rebuild

make: Entering directory '/root/node_modules/int64-napi/build' CC(target) Release/obj.target/int64/c/int64.o SOLINK_MODULE(target) Release/obj.target/int64.node COPY Release/int64.node make: Leaving directory '/root/node_modules/int64-napi/build'

rclnodejs@0.21.4 install /root/node_modules/rclnodejs node-gyp rebuild

Unable to detect ROS, please make sure a supported version of ROS is sourced. gyp: Call to 'node scripts/ros_distro.js' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16) gyp ERR! stack at ChildProcess.emit (events.js:400:28) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12) gyp ERR! System Linux 4.9.299-tegra gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /root/node_modules/rclnodejs gyp ERR! node -v v14.21.1 gyp ERR! node-gyp -v v5.1.0 gyp ERR! not ok npm WARN dtslint@4.2.1 requires a peer of typescript@>= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev but none is installed. You must install peer dependencies yourself. npm WARN tslint@5.14.0 requires a peer of typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev but none is installed. You must install peer dependencies yourself. npm WARN dts-critic@3.3.11 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself. npm WARN tsutils@2.29.0 requires a peer of typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev but none is installed. You must install peer dependencies yourself. npm WARN ledeinaus34@1.0.0 No description npm WARN ledeinaus34@1.0.0 No repository field.

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! rclnodejs@0.21.4 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the rclnodejs@0.21.4 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-12-22T09_07_38_186Z-debug.log The command '/bin/sh -c npm update' returned a non-zero code: 1

There is my code:

FROM ubuntu:20.04

RUN apt-get update && apt-get upgrade -y

ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8

RUN apt-get update && apt-get install -y curl gnupg2 lsb-release RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ros-foxy-desktop

RUN apt-get install -y python3-colcon-common-extensions \ python3-rosdep \ python3-argcomplete \ && rm -rf /var/lib/apt/lists/*rm

WORKDIR /root/dd_ws/src RUN apt update && apt-get install git -y RUN git clone https://github.com/ros/ros_tutorials.git -b foxy-devel WORKDIR /root/dd_ws RUN apt-get install python3-rosdep -y RUN rosdep init RUN rosdep update RUN rosdep install -i --from-path src --rosdistro foxy -y

COPY ros2_entrypoint.sh /root/. ENTRYPOINT ["/root/ros2_entrypoint.sh"]

WORKDIR /root

RUN apt-get update && apt-get upgrade -y

RUN apt-get install --yes curl RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install --yes nodejs RUN apt-get install --yes build-essential RUN node -v RUN npm -v

COPY . /public

COPY package*.json ./

RUN npm install -g dot-json && dot-json package.json dependencies.rclnodejs ^0.21.4

RUN npm cache clean --force && npm install -g uuid@7.0.3 --force RUN rm -rf node_modules RUN rm package-lock.json RUN apt install libpq-dev RUN npm update RUN npm install

COPY . .

EXPOSE 8040

CMD ["node", "/app.js"]

please can you help me?

gildas04 commented 1 year ago

Hi, i solved it with that: https://github.com/RobotWebTools/ros2-web-bridge/issues/151 thanks

minggangw commented 1 year ago

Sorry for the delay, glad to hear you have solved the problem.