Repo2docker: npm install not permitted

Created on 10 May 2018  路  6Comments  路  Source: jupyterhub/repo2docker

In https://github.com/jupyterhub/binderhub/issues/558 @aborruso reports:

Hi,
I have npm install -g mapshaper in postBuild, but I'm blocked because I'm not root.

Is there another way to install a nodejs package and have it ready to use after building?

Thank you

Does anyone remember why we decided that postBuild should not run as root?

enhancement

All 6 comments

In general, you should not run things as root unless absolutely required. npm has ways to install things as non-root, so those should be preferred. If you need to use root, you should use a Dockerfile. It would be great to have an example that shows how to do this.

For example, with mapshaper, I could install it without root with:

npm install  mapshaper

And then access the commandline utilities as

./node_modules/.bin/mapshaper

Hope that is helpful!

@yuvipanda yes it's helpful thank you.

But without this PR it would be less comfortable.

Now /home/jovyan/local/bin is in the PATH and I have added this to postBuild

npm install mapshaper --prefix /home/jovyan/local/bin
cd /home/jovyan/local/bin
ln -s /home/jovyan/local/bin/node_modules/mapshaper/bin/mapshaper mapshaper

And I have my utilty ready to use, without using absolute path :)

Closing this as we now have a solution to this problem. Feel free to re-open if needed.

indeed! thanks for the quick fix @aborruso and the subsequent .local patch in #313 @yuvipanda !

If we installed npm itself with conda or nvm, then npm install -g would work without permission issues. I think there's also an NPM_ROOT/PREFIX env or something that should specify where -g installs would go. That could be pointed to a prefix that's on PATH and user-writable.

(reopened as Min's suggestion sounds like something we should implement)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

betatim picture betatim  路  6Comments

choldgraf picture choldgraf  路  4Comments

bitnik picture bitnik  路  3Comments

trallard picture trallard  路  4Comments

NHDaly picture NHDaly  路  6Comments