
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Browser package management with modular dependency and version management. https://jspm.io
npm install jspm -g
cd my-project
jspm init
No package.json found, would you like to create one? [yes]:
Enter package name [app]:
Enter application folder [lib]:
Enter packages folder [jspm_packages]:
Enter config file path [config.js]:
Configuration file config.js not found, create it? [y]:
Downloading loader files to jspm_packages
system@0.4.0.js
es6-module-loader@0.4.1.js
traceur@0.0.10.js
ok Loader files downloaded successfully
ok Verified package.json at package.json
Verified config file at config.js
The application name is used to require anything from the application code folder lib
, instead of from the jspm registry.
A require to app/main
will load lib/main.js
in this example.
Sets up the package.json and configuration file, and downloads the jspm SystemJS loader files.
jspm install npm:lodash-node
jspm install github:components/jquery
jspm install jquery
Any npm or Github package can be installed in this way.
Most npm packages will install without any configuration necessary. Github packages may need to be configured for jspm first. Read the guide here on configuring packages for jspm.
All installs are saved into the package.json, so that the jspm_packages folder and configuration file can be entirely recreated with a single jspm install
call with no arguments. This is ideal for version-controlled projects where third party packages aren't saved in the repo itself.
The config.js file is updated with the version information and the version is locked down.
config.js
), then load the modules:<script src="jspm_packages/system@0.4.0.js"></script>
<script src="config.js"></script>
<script>
System.import('npm:lodash-node/modern/objects/isEqual').then(function(isEqual) {
});
System.import('github:components/jquery').then(function($) {
});
System.import('jquery').then(function($) {
});
</script>
jspm install github:my/module
.Read the guide on configuring packages for jspm here.
If you are having any trouble configuring a package for jspm, please just post an issue and we'll help get it configured.
jspm install jquery
Automatically downloads and sets the configuration map for the loader.
This is equivalent to writing:
jspm install jquery=github:components/jquery
The jspm registry just provides a mapping from a name into an endpoint package name.
The npm and Github endpoints are both served by CDN, which is automatically configured in jspm.
We can switch the CDN version with a single command:
jspm setmode remote
This updates the configuration to now load all the packages from the CDN directly instead of the jspm_packages
folder. The app will still behave identically, but we retain the version-lock configuration.
Revert back to the local files with:
jspm setmode local
The CDN can be used for production as sources are provided minified with SPDY and optimal cache headers.
When moving to production with an app using CDN sources, the jspm CLI can inject package configuration and lock down versions minimising the production requests.
To inject the configuration locking down an exact version of a module, use jspm inject
.
A specific package can have its configuration injected and version locked down with:
jspm inject jquery
All the packages in the package.json can be injected (like the install command) with:
jspm inject
This provides an alternative workflow to installation when using the CDN.
jspm update
All packages will be checked, and versions upgraded where necessary.
jspm provides some operations for convenience:
Minification is provided for convenience only, while transpiling is provided as a fundamental use case for ES6 module usage.
Application code is stored in the lib
directory, which is also stored in the package.json as:
package.json:
{
"directories": {
"lib": "lib"
}
}
When building, this is the directory that we build.
To set build options, add a directories.dist
and a buildConfig
object to the package.json:
package.json:
{
"directories": {
"lib": "lib",
"dist": "lib-built"
},
"buildConfig": {
"minify": true,
"transpile": true
}
}
To run the build, use the command:
jspm build
To run the application from the built sources, use the command:
jspm setmode production
The baseURL
in the configuration file will be updated to the build directory, and the app will load its resources from there.
To try out a demonstration of this, clone the ES6 demo repo here.
Use -f
or --force
with the install command to overwrite and redownload all dependencies.
Use -h
or --https
to download with https instead of alternative protocols.
Use -o
or --override
to force-set the package override for a package that needs extra configuration. See https://github.com/jspm/registry#testing-package-overrides.
To set GitHub authentication to avoid rate limits, enter your GitHub credentials with:
jspm config github.username myusername
jspm config github.password mypassword
jspm --help
for command list.Apache 2.0
FAQs
Import Map Package Manager
The npm package jspm receives a total of 3,747 weekly downloads. As such, jspm popularity was classified as popular.
We found that jspm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.