ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Try to use NPM with ROS melodic on Ubuntu 18.04.

asked 2019-12-14 11:21:22 -0500

xavier12358 gravatar image

updated 2022-01-22 16:10:12 -0500

Evgeny gravatar image


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?

edit retag flag offensive close merge delete


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?

rubicks gravatar image rubicks  ( 2019-12-14 12:56:37 -0500 )edit

Exactly. I believe the first thing to do for @xavier12358 would be to clarify what the precise problem is.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-19 03:00:58 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-12-14 12:43:52 -0500

rubicks gravatar image

updated 2020-01-03 10:17:36 -0500

Update: I was mistaken. Not only is nodejspackaged for most recent Ubuntu releases, it's also been a rosdep package since at least 2014:

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

# my_catkin_project/package.xml

# 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 --recv-key 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280

Point your apt to their repository:

# /etc/apt/sources.list.d/nodejs.list
deb bionic main
deb-src 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
  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
... will delegate to apt the installation of the package (if it's not already installed).

edit flag offensive delete link more


Thank you I try it, and it works properly.

xavier12358 gravatar image xavier12358  ( 2019-12-19 03:03:06 -0500 )edit

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

elegolo gravatar image elegolo  ( 2020-01-02 17:04:52 -0500 )edit

@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?

gvdhoorn gravatar image gvdhoorn  ( 2020-01-03 06:10:16 -0500 )edit

@gvdhoorn, why wouldn't I?

rubicks gravatar image rubicks  ( 2020-01-03 09:30:08 -0500 )edit

If catkin build didn't error out with angry messages to the contrary, I'd probably drop it. So it goes...

rubicks gravatar image rubicks  ( 2020-01-03 10:14:48 -0500 )edit

Oh, whoops, you meant instead of the recommended catkin_package, and not the complete lack of _anything_ catkin_*-flavored. My bad. Will edit forthwith.

rubicks gravatar image rubicks  ( 2020-01-03 10:16:59 -0500 )edit

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.

rubicks gravatar image rubicks  ( 2020-01-03 10:20:47 -0500 )edit

Question Tools



Asked: 2019-12-14 11:21:22 -0500

Seen: 1,189 times

Last updated: Jan 03 '20