
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
reinstall-node-modules
Advanced tools
Have you ever been in the situation you were facing an issue that was simply caused by not having (re)installed node modules after someone had changed it?
Are you tired of telling people to (re)install their node modules when they ask you why something is not working?
This lightweight package might be the perfect solution for you! It (re)installs node modules whenever the target package file has changed!
Install the package with your favorite manager
npm install reinstall-node-modules --save-dev
yarn add reinstall-node-modules --dev
You may use it in the scripts
field of your package.json
{
"scripts": {
"reinstall": "reinstall-node-modules"
}
}
However it's highly recommended to use a git hook to run it! There's no other way to make sure everybody has the correct node modules!
If you wanna use a hook for this it's recommended to use post-merge
. An easy way to use git hooks is the husky package what would require to add the following to your package.json
{
"husky": {
"hooks": {
"post-merge": "reinstall-node-modules"
}
}
}
It's also possible import the package and use it programmatically though most of the time an npm-script or hook makes more sense.
const installer = require('reinstall-node-modules');
const options = {};
installer(options);
Option | Type | Default |
---|---|---|
manager | string | 'npm' |
file | string | 'package.json' |
install | boolean | true |
updateHash | boolean | true |
notify | boolean | false |
The manager option defines the package manager that gets used to (re)install the node modules. By default it's npm
but you can use whatever you like (as long as it supports the install
command).
If you wanna e.g. use yarn
instead of npm
you only need to pass it as option
reinstall-node-modules --manager yarn
The file option defines the path to the target package file that gets used to determine whether it's necessary to (re)install node modules or not (based on its content). You can use either a relative or an absolute path here. By default it's package.json
assuming there's such a file in your current working directory.
If you wanna e.g. use package-lock.json
instead of package.json
you only need to pass it as option
reinstall-node-modules --file package-lock.json
The install option defines if an actual (re)install is executed.
So to disable it you only need to set it false
reinstall-node-modules --install false
The updateHash option defines if a *.hash file is written to disk. Be careful with disabling this because your target package file will be considered as changed then every time.
reinstall-node-modules --update false
The notify option defines if a notification gets sent in case the target package file has changed. This is in particular useful if you have disabled install
to gently inform your colleagues they should (re)install their node modules.
reinstall-node-modules --notify true
Usually you set the options via command line arguments (e.g. --install false
).
If you prefer a config file instead just create a reinstall-node-modules.json
file in your process cwd.
This package is inspired by install-changed.
Last but not least, if this package is helpful to you it'll be great when you give me a star on github and share it. Keeps me motivated to continue the development.
FAQs
(re)install node modules only if they have changed
The npm package reinstall-node-modules receives a total of 19 weekly downloads. As such, reinstall-node-modules popularity was classified as not popular.
We found that reinstall-node-modules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.