
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
root_require
Advanced tools
Hijacks node's module resolution so that you can use a prefixed path to require modules from the project root.
Hijacks node's module resolution so that you can use a prefixed path to require modules from the project root.
If you want to accomplish this by transforming your code rather than using this runtime node hack, or for bundling for the browser, use babel-plugin-root-require.
$ npm install root_require
require('root_require').setRoot()
const myThing = require('~/things/relatively')
Starting from your project root, if you have a file lib/foo.js and you want to require it from routes/user/profile, you would normally write require('../../../lib/foo'). With root_require initialized, you can just write require('~/lib/foo') from anywhere.
setRoot(pathToRoot)If no argument is given, setRoot will look for a package.json and consider the directory it is found in to be the root.
setPrefix(prefix)The prefix to use to refer to the project root.
require('root_require').setPrefix('TATERS').setRoot()
require('TATERS/foo.js')
reset()Restore module resolution to default behavior. You probably don't ever need to do this.
FAQs
Hijacks node's module resolution so that you can use a prefixed path to require modules from the project root.
We found that root_require 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.