[NodeJS] npm install gyp error - Value error : invalid mode : 'rU' while trying to load binding.gyp
I'm trying to install npm packages with npm i
in my node application but it's getting failed due to the error Value error : invalid mode : 'rU' while trying to load binding.gyp
. Can anyone help me on this?
ValueError: invalid mode: 'rU' while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 22.1.0
gyp ERR! command \".nvm/versions/node/v16.18.1/bin/node\" "path/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd path/node_modules/watchpack-chokidar2/node_modules/fsevents
gyp ERR! node -v v14.19.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
2 Answers
I assume, this error happens because of Node JS and/or node-gyp versions.
You should update Node and/or node-gyp. This might fix the error.
Good luck :)
In my case, I had python 3.11 installed on my machine, where node-gyp requires that you have any of these compatible versions v3.7, v3.8, v3.9 or v3.10. Downgrading the python version to 3.10 solves the issue for me.
Check the version of the python installed and you can also set npm's 'python' config key to apppropriate compatible one if you have multiple versions of python installed using the below command.
npm config set python /path-to-executable-python