
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
copy-module-alias
Advanced tools
@ in your linked module names, there is a risk this module will cause data lossSee this issue https://github.com/Rush/link-module-alias/issues/3
Setup private modules within your repo to get away from error-prone typing of long relative paths like these:
require('../../../../some/very/deep/module')
Just create an alias and do it cleanly:
var module = require('@deep/module')
// Or ES6
import module from '@deep/module'
You can setup aliases both to individual files and to directories.
WARNING Use this module only in final applications. It will not work inside published npm packages.
npm i --save-dev copy-module-alias
Add your custom configuration to your package.json (in your application's root), and setup automatic initialization in your scripts section.
Note: you can use @ in front of your module but before of the possible data loss https://github.com/Rush/link-module-alias/issues/3
"scripts": {
"postinstall": "copy-module-alias"
},
// Aliases
"_moduleAliases": {
"~root" : ".", // Application's root
"~deep" : "src/some/very/deep/directory/or/file",
"@my_module" : "lib/some-file.js", // can be @ - but see above comment and understand the associated risk
"something" : "src/foo", // Or without ~. Actually, it could be any string
}
If you encounter issues with installing modules, you may want to set up the preinstall script as well:
"scripts": {
"postinstall": "copy-module-alias",
"preinstall": "command -v copy-module-alias && copy-module-alias clean || true"
}
"main" that points to the target fileThis module it's almost a drop in replacement for another package https://www.npmjs.com/package/module-alias - use module module-alias if you like runtime require hooks and use copy-module-alias if you want good compatibility with your IDE and no runtime hacks.
The key differentiator of copy-module-alias is copying all modules statically in form of symlinks and proxy packages inside node_modules, there is no hacky require hook and you don't need to load any supporting packages.
The key motivator to create copy-module-alias was to make it work in environments that don't support symlinks.
MIT. Attribution to the module-alias for parts for the README and original idea.
FAQs
Create file copies links for _moduleAliases
We found that copy-module-alias 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.