Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
require-one
Advanced tools
Load the first package found from the given array.
Method | Installation |
---|---|
npm | npm install require-one --save |
component | component install robloach/require-one |
Composer | composer require require-one |
Bower | bower install require-one |
This works across CommonJS/node, AMD and with global variables for the browser.
This is an example of loading either jQuery, Zepto, or Cheerio with a CommonJS module loader, like Node.js.
var $ = requireOne('jquery', 'zepto', 'cheerio');
// => jQuery, Zepto or Cheerio, depending on which one is available.
This is an example of loading either jQuery, Zepto, or Cheerio with an AMD module loader, like Require.js.
require(['require-one'], function(requireOne) {
// Retrieve the first package that is available.
var $ = requireOne('jquery', 'zepto', 'cheerio');
// => jQuery, Zepto or Cheerio, depending on which one is available.
// ...
});
This is an example of loading either jQuery, Zepto, or Cheerio without a module loader, i.e. with the browser's global variables.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="path/to/require-one.js"></script>
<script>
var $ = requireOne('jquery', 'jQuery', 'zepto', 'Zepto', 'cheerio');
// => jQuery, Zepto or Cheerio, depending on which one is available.
</script>
</head>
<body>
<h1>My Sample Project</h1>
</body>
</html>
FAQs
Require the first found package from an array.
We found that require-one 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.