Ask Your Question
2

Try to use NPM with ROS melodic on Ubuntu 18.04.

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

xavier12358 gravatar image

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?

edit retag flag offensive close merge delete

Comments

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 imagerubicks ( 2019-12-14 12:56:37 -0600 )edit

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

gvdhoorn gravatar imagegvdhoorn ( 2019-12-19 03:00:58 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

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

rubicks gravatar image

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

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

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).

edit flag offensive delete link more

Comments

Thank you I try it, and it works properly.

xavier12358 gravatar imagexavier12358 ( 2019-12-19 03:03:06 -0600 )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 imageelegolo ( 2020-01-02 17:04:52 -0600 )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 imagegvdhoorn ( 2020-01-03 06:10:16 -0600 )edit

@gvdhoorn, why wouldn't I?

rubicks gravatar imagerubicks ( 2020-01-03 09:30:08 -0600 )edit

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

rubicks gravatar imagerubicks ( 2020-01-03 10:14:48 -0600 )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 imagerubicks ( 2020-01-03 10:16:59 -0600 )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 imagerubicks ( 2020-01-03 10:20:47 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 74 times

Last updated: Jan 03