How to install npm on Streamlit Community Cloud

I have a Python project that requires a certain npm package that needs to be run from the command line. How to achieve this on the Community Cloud?

Here are the things that needs to be done:

  1. Install npm
  2. Install that package using npm command like npm install package-name
  3. Execute a command to run the install npm package, something like package-name filename. Can this be done using os.subprocess within a Python script?

I was wondering if there was a way to achieve all these 3 pointers?

Theoretically you could do that with os.subprocess, but I would encourage you to instead look for a python package that has the functionality you’re looking for. I suspect that, at a minimum, you will run into permissions issues if you try to install a package as the app is running. But, you can certainly give it a try. I would certainly test it locally first, and see if you can get that to happen from inside your streamlit_app.py file.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.