Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run npm install without node-gyp rebuild

Tags:

node.js

npm

I do a node-gyp rebuild in my post install scripts. Running node-gyp rebuild during will error out. How can I run npm install without node-gyp rebuild?

like image 434
Dr.Knowitall Avatar asked Sep 26 '16 17:09

Dr.Knowitall


People also ask

How do I get rid of gyp error?

Please uninstall node. js and use the Node v14. x. It will solve it automatically.

Why do we need node-gyp?

node-gyp is a tool that enables the compilation of native add-on modules for Node in multiple platforms. It has widespread use and is included as a dependency in many NPM packages. On most systems, this isn't an issue, and installing node-gyp with the rest of your packages works as expected.

Can npm run without node?

To publish and install packages to and from the public npm registry or a private npm registry, you must install Node. js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager like nvm to install Node. js and npm.

Do I need to install node-gyp?

node-gyp dependencies If you only need to compile add-ons during the project setup, Node. js should cover it for you. However, if you are an add-on developer, you probably need to install node-gyp globally. To use node-gyp, first, we'll need to install a Python runtime, the make utility, and a C or C++ compiler.


2 Answers

You can do:

npm install --ignore-scripts

But it's not perfect because it prevents to execute all scripts from all dependencies.

like image 81
Paleo Avatar answered Oct 03 '22 20:10

Paleo


Well if you don't want to install using npm install --ignore-scripts a for some reason use npm install only, you can override install script in package.json by some noop. For example:

"scripts" : {
    "install" : "echo"
}

works like a charm (tested with yarn too)

like image 25
Daniel Stejskal Avatar answered Oct 03 '22 21:10

Daniel Stejskal