Whenever I install certain node
packages, there are errors involving the Python
version. This is because I have both Python 2.7
and Python 3.3
(those were the latest versions last time I updated, but now there is 3.4
), but obviously I can only source one version in my PATH
(any later folders are overridden). I have Python 3.3
in my PATH
because it's newer, but there are still so many programs, including npm
modules, which use Python 2
, over 5 years later.
Is there any way to include a "fallback" Python
version, for modules which can not use version 3 yet? A general solution would be amazing, but I would at least like a solution for when installing npm
modules. Keep in mind that some modules may be perfectly fine with Python 3
, though I'm not sure if there are any which can not use Python 2
. With that said, a solution which allows both, using the newest version when compatible and some older version when not, would be best.
For reference, my Python 2.7
is installed in the C:\Python27\python
folder and Python 3.3
is in the C:\Python33\python
folder. The npm
error I am getting is:
[email protected] install c:\repos\konneka\node_modules\buster\node_modules\bus ter-syntax\node_modules\jsdom\node_modules\contextify node-gyp rebuild
|
c:\repos\konneka\node_modules\buster\node_modules\buster-syntax\node_modules\jsd
om\node_modules\contextify>node "c:\Program Files\nodejs\node_modules\npm\bin\no
de-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
[email protected] node_modules\buster\node_modules\buster-server-cli\node_modules\buste
r-cli\node_modules\buster-configuration\node_modules\when
[email protected] node_modules\buster\node_modules\buster-test-cli\node_modules\ramp\
node_modules\ramp-resources\node_modules\lodash
gyp ERR! configure error
gyp ERR! stack Error: Python executable "python" is v3.3.2, which is not support
ed by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & <
3.0.0.
gyp ERR! stack at failPythonVersion (c:\Program Files\nodejs\node_modules\np
m\node_modules\node-gyp\lib\configure.js:108:14)
gyp ERR! stack at c:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:97:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:645:7)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at maybeClose (child_process.js:755:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:822:
5)
ERR! System Windows_NT 6.2.9200
command "node" "c:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\nod
e-gyp\\bin\\node-gyp.js" "rebuild"
[email protected] node_modules\browserify\node_modules\syntax-e
rror\node_modules\esprima-fb
[email protected] node_modules\karma\node_modules\http-proxy
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected].
0)
cwd c:\repos\konneka\node_modules\buster\node_modules\buster-syntax\node_module
s\jsdom\node_modules\contextify
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
If you need to use a different version of npm for each project, there are a number of possible solutions. Probably the lightest-weight version is to use npx . A semi-common use-case for this can be projects that use lock-file v1 and another that uses lock-file v2. v2 was introduced in npm v7.
Due to https://github.com/npm/npm/issues/2943, npm will never support the ability to alias packages and install multiple versions of the same package.
If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.
Use virtualenv and nodeenv and have any version combination you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With