0
$\begingroup$

Rosanswers logo

Hello,

I use ROS melodic on Ubuntu 18.04 and I want to also use npm. When I try to install npm, this uninstall ROS.

How could I resolve that problem?


Originally posted by xavier12358 on ROS Answers with karma: 62 on 2019-12-14

Post score: 3


Original comments

Comment by rubicks on 2019-12-14:
I can't tell from your question the nature of the conflict you describe. Is it that apt sees some Conflicts: and/or Replaces: between a ros-melodic-* package and the nodejs package?

Comment by gvdhoorn on 2019-12-19:
Exactly. I believe the first thing to do for @xavier12358 would be to clarify what the precise problem is.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Update: I was mistaken. Not only is nodejs packaged for most recent Ubuntu releases, it's also been a rosdep package since at least 2014: https://github.com/ros/rosdistro/commit/58e3227d9

So, what you have to do is a lot smaller; i.e.,

# my_catkin_project/package.xml
...
  <depend>nodejs</depend>
...

# my_catkin_project/CMakeLists.txt
...
catkin_package(my_catkin_project DEPENDS nodejs)
...

Original answer follows.


Buckle up --- this is a multi-step process.

First, tell apt where to find the node stuff. Follow their instructions, or, if you're feeling fancy...

Get their pubkey:

root@mybionic:~# apt-key adv --keyserver keyserver.ubuntu.com --recv-key 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280

Point your apt to their repository:

# /etc/apt/sources.list.d/nodejs.list
deb     https://deb.nodesource.com/node_10.x bionic main
deb-src https://deb.nodesource.com/node_10.x bionic main

And update your apt cache:keycode 64 = Alt_L NoSymbol Alt_L keycode 92 = Alt_R NoSymbol Alt_R keycode 108 = Alt_R NoSymbol Alt_R

root@mybionic:~# apt update

Next, you have to convince rosdep (read "lie") that there is a ROS package called nodejs which, for each and every ROS-supported Operating System, is called nodejs. This fakery requires two files, one "rosdep yaml" file to provide the aforementioned associations...

# /var/lib/rosdep/nodejs.yaml
nodejs:
  arch: [nodejs]
  cygwin: [nodejs]
  debian: [nodejs]
  fedora: [nodejs]
  freebsd: [nodejs]
  gentoo: [nodejs]
  opensuse: [nodejs]
  osx: [nodejs]
  rhel: [nodejs]
  ubuntu: [nodejs]

...and one "rosdep list" file to tell rosdistro about the yaml file:

# /etc/ros/rosdep/sources.list.d/nodejs.list
yaml file:///var/lib/rosdep/nodejs.yaml

Note that the rosdep yaml can live anywhere you want, but, given that this is stateful file whose contents affect the entire ROS installation, it makes sense to put it somewhere only root can touch it. Note also that, since bloom v0.8.0, it's not enough to configure for a proper subset of supported platforms --- you have to configure for all of them.

After emplacing the rosdep yaml and rosdep list, you can rosdep update. Now, when rosdep sees...

# my_catkin_project/package.xml
...
    <depend>nodejs</depend>
...

...it will delegate to apt the installation of the package (if it's not already installed).


Originally posted by rubicks with karma: 193 on 2019-12-14

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by xavier12358 on 2019-12-19:
Thank you I try it, and it works properly.

Comment by elegolo on 2020-01-02:
Great, that helped a lot. Despite in 'melodic' there seemed to be a change from catkin_project(my_catkin_project DEPENDS nodejs) to catkin_package(DEPENDS nodejs) in file CMakeLists.txt

Comment by gvdhoorn on 2020-01-03:
@elegolo: that must have been a very old package, because catkin_project(..) was used with the ROS Fuerte version of Catkin only. It's mentioned in the migration guide.

@rubicks: why did you use the catkin_project(..) macro in your answer?

Comment by rubicks on 2020-01-03:
@gvdhoorn, why wouldn't I?

Comment by gvdhoorn on 2020-01-03:
Because it's old and not supposed to be used? See catkin 0.7.20 documentation » How to do common tasks » Package format 2 (recommended) » Catkin configuration overview: CMakeLists.txt fi and wiki/catkin/CMakeLists.txt: catkin_package().

Comment by rubicks on 2020-01-03:
If catkin build didn't error out with angry messages to the contrary, I'd probably drop it. So it goes...

Comment by rubicks on 2020-01-03:
Oh, whoops, you meant instead of the recommended catkin_package, and not the complete lack of anything catkin_*-flavored. My bad. Will edit forthwith.

Comment by rubicks on 2020-01-03:
Fixed. I'll accept most of the blame for this one, but the extremely ambiguous (and overloaded) verbiage didn't help. They are "catkin projects" as they exist in source, but, once bloomed and built, they become "packages" --- which is itself ambiguous in that the context could be catkin, ROS, and/or OS packages. It's a confusing landscape.

Comment by gvdhoorn on 2020-01-03:
I don't really follow you, but at least the answer is now correct.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.