Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node.js install Python dependencies from within package.json

I’m building a Node.JS project that uses both Python and NPM dependency modules.

The Node.JS modules are located within package.json and the python dependencies are inside a file requirements.txt.

I would like to install all the dependency modules (Python and Node.JS) from within package.json by running npm install.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is this possible and how?

Thanks in advance!

The files look like below.

package.json:


{
  "name": "app",
  "version": "1.0.0",
  "description": "Trial app",
  "main": "bin/index.js",
  "scripts": {
    "dev": "npm install",
    "start": "node app.js",
    "test": "jest --forceExit "
  },
  "keywords": [
    "AI",
    "Blockchain",
    "Decentralized"
  ],
  "dependencies": {
    "peerjs": "^1.3.2",
    "redis": "^3.1.2",
    "socket.io": "^4.1.2",
    "socket.io-client": "^4.1.2",
    "wrtc": "^0.4.7"
  },
  "devDependencies": {
    "@babel/core": "^7.16.7",
    "supertest": "^6.1.6"
  }
}

requirements.txt:


Django==2.2.21
djangorestframework==3.7.7
django-rest-swagger
coreapi

>Solution :

You can define Commands to run within the "scripts" section of your package.json. Every script in there can be run with npm run [scriptname].

So you could do (&& runs another command after the first one)

"scripts": {
    "install": "npm install && pip -r requirements.txt",
    "dev": "npm install",
    "start": "node app.js",
    "test": "jest --forceExit "
  }

And run npm run install

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading