
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
strict-import
Advanced tools
Prevent
requirefrom searching upwards for required modules
The require() algorithm works by searching for a node_modules directory with your required module from the current directory and upwards until it reaches the system root directory.
This means that if you have nested projects, and have a module called foo installed at the top-level, the sub-projects can also import foo without installing it. While useful in some cases, it can also cause problems.
I made this module because I'm working on an Electron app, where we use electron-builder with a two package structure. We depended on module foo in the renderer, which was defined top-level, since we use Webpack for bundling. We later started using foo in the main process code too, which is placed in an app subdirectory. The problem is that we forgot to add foo as a dependency in the app directory, but it worked fine in development as require just found it at the top-level. In production, however, it crashed, since we no longer had the top-level dependency, as only the app directory is included in the built app. With this module, we can ensure that doesn't happen again.
$ npm install strict-import
At the top of your index.js file.
require('strict-import')(module);
// This now only works if `foo` is in `./node_modules`,
// but not if it's in `../node_modules`
const foo = require('foo');
MIT © Sindre Sorhus
FAQs
Prevent `require` from searching upwards for required modules
The npm package strict-import receives a total of 2 weekly downloads. As such, strict-import popularity was classified as not popular.
We found that strict-import 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.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.