
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
import-local
Advanced tools
Let a globally installed package use a locally installed version of itself if available
The import-local npm package is designed to allow a globally installed package to defer to a locally installed version of itself when it is being run within a project that has that package as a dependency. This is useful for testing local changes to a package without having to publish the package or modify the global version.
Deferring to local version
This code checks if a local version of the package is available. If it is, it will use the local version and log a message to the console. Otherwise, it will proceed with the global package's code.
if (importLocal(__filename)) {
console.log('Using local version of this package');
} else {
// Code for the global package goes here
}
The resolve-from package allows you to resolve a module path from a given root directory. It's similar to import-local in that it helps with module resolution, but it doesn't automatically defer to a local version of a package.
Require-local is another package that allows for requiring modules from a local context. It's similar to import-local but does not provide the automatic deferring mechanism to local versions when a global version is run.
Linklocal can link local dependencies for development purposes. It's similar to import-local in that it helps with using local versions of packages, but it works by creating symlinks rather than deferring when a global version is executed.
Let a globally installed package use a locally installed version of itself if available
Useful for CLI tools that want to defer to the user's locally installed version when available, but still work if it's not installed locally. For example, AVA and XO uses this method.
npm install import-local
import importLocal from 'import-local';
if (importLocal(import.meta.url)) {
console.log('Using local version of this package');
} else {
// Code for both global and local version here…
}
You can also pass in __filename
when used in a CommonJS context.
FAQs
Let a globally installed package use a locally installed version of itself if available
The npm package import-local receives a total of 37,238,242 weekly downloads. As such, import-local popularity was classified as popular.
We found that import-local demonstrated a healthy version release cadence and project activity because the last version was released less than 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.