15

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

reddfox
  • 167
  • 1
  • 1
  • 9

3 Answers3

20

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.

brc-dd
  • 10,788
  • 3
  • 47
  • 67
  • 1
    I didn't need to downgrade npm, but editing the config directly helped solve my issue indeed. Still curious why npm config set didn't work though. Thanks! – reddfox Nov 21 '22 at 18:14
0

Update your npm

npm install -g npm@^8

Retry the command

npm config set python C:\Python27\python.exe
Enrico
  • 2,734
  • 1
  • 27
  • 40
-1

Consider running fix command:

npm config fix

In my case, it resolved the issue