39

I am starting up with node This is from node.js README.md

Prerequisites (Unix only):

* GCC 4.2 or newer
* Python 2.6 or 2.7
* GNU Make 3.81 or newer
* libexecinfo (FreeBSD and OpenBSD only)

Curious to know why does node.js need Python ? Does it use Python underneath its API

binithb
  • 1,910
  • 4
  • 23
  • 44
  • 2
    https://github.com/joyent/node/wiki/Installation "python 2.6 or 2.7. The build tools distributed with Node run on python." – M4rtini May 17 '14 at 09:32

2 Answers2

38

Node.js is built with GYP — cross-platform built tool written in Python. Also some other build steps are implemented in Python. So Python is required for building node from source.

But you also need Python for building native addons.

vkurchatkin
  • 13,364
  • 2
  • 47
  • 55
  • 3
    has there ever been a conversation on converting the node.js depending on python through gyp to something native (like node,js itself)? – Brandon Ros Apr 03 '20 at 15:22
  • @BrandonRos, here is one from 2015-2017, though I wish I knew of a more recent one: https://github.com/nodejs/NG/issues/24 – Marcus May 21 '20 at 21:48
  • @BrandonRos here are a couple more: https://github.com/nodejs/node-gyp/issues/1791 https://github.com/nodejs/TSC/issues/648 – Marcus May 22 '20 at 00:01
3

Yes, node uses some python scripts under the hood, though Node is largely written in C++.

See some of Node's python code here:

https://github.com/joyent/node/tree/master/tools

E.g., js2c.py converts Javascript into C-style char arrays:

https://github.com/joyent/node/blob/master/tools/js2c.py

In general, if a package tells you that it requires Python, then it is almost certainly using Python ;)

Icarus
  • 131
  • 5
  • 2
    It sure is using Python :) . But is Python used just during installation or during the run time of node scripts as well ? If the latter will it affect the performance in those cases – binithb May 17 '14 at 09:43
  • 1
    Python is not used at runtime. – Icarus May 17 '14 at 13:39