reddfox
reddfox

Reputation: 397

python is not a valid npm option

I am trying to set an older version of python in order to install modules and build an old node project.

I run this command:

npm config set python=python2.7

OR

npm config set python C:\Python27\python.exe

In both cases I am getting this error:

npm ERR! `python` is not a valid npm option 

Nove v16.14.2

Npm v9.1.2

Upvotes: 25

Views: 39961

Answers (4)

SpiesInOrbit
SpiesInOrbit

Reputation: 1

Running Raspberry Pi node v20.18.2 code on my Ubuntu 22.04 I was able to install with the following:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
npm install --python=/usr/bin/python

I didn't go back and update my python back to 3.10.12 since I run python with "python3" instead of "python".

Upvotes: 0

Enrico
Enrico

Reputation: 3479

Update your npm

npm install -g npm@^8

Retry the command

npm config set python C:\Python27\python.exe

Upvotes: -1

Consider running fix command:

npm config fix

In my case, it resolved the issue

Upvotes: -3

brc-dd
brc-dd

Reputation: 13129

Consider downgrading npm to v8 for now:

npm install -g npm@^8

Alternatively, just run:

npm config edit

and add:

python=C:\Python27\python.exe

in a new line.

Upvotes: 41

Related Questions