Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between jspm install and npm install

Tags:

I'm relatively new to jspm. I wanted to know what the difference is when is run jspm install package and npm install package. I know that there is a lookup with jspm/registry. But what's the difference when it comes to setting up config.js. Are there any additional changes to be made if the package is installed using npm?

like image 811
Sahil Jain Avatar asked Aug 24 '16 11:08

Sahil Jain


People also ask

What is the difference between npm install and npm install?

Currently they will not differ at all. Since NPM 5 packages are automatically saved into package. json dependencies when installed. npm I is the short version of npm install so that part of the command does not differ at all either.

What is the difference between Yarn install and npm install?

Speed and Performance As mentioned above, while NPM installs dependency packages sequentially, Yarn installs in-parallel. Because of this, Yarn performs faster than NPM when installing larger files. Both tools also offer the option of saving dependency files in the offline cache.

What is JSPM?

jSPM, or JavaScript Package Manager, functions on top of the SystemJS universal module – which was developed by Guy Bedford. SystemJS is essentially a module loader that offers the user the ability to import modules at runtime in a variety of popular formats (i.e. UMD, AMD, ES6, etc.).

Is there any difference between npm I & npm install?

There is no difference, since "npm i" is an alias for "npm install". They both do the exact same thing (install or update all the dependencies in your package-lock.


2 Answers

npm and jspm are both package managers.
npm is used for the node ecosystem, and traditionally served back-end dependencies.

To enforce the separation between front-end and back-end, developers used tools specifically for front-end. There came bower and the likes... as well as jspm.


I wanted to know what the difference is when is run jspm install package and npm install package.

Here are some differences between npm and jspm:
- jspm stores its dependencies in jspm_packages whereas npm stores them in node_modules
- jspm uses a flat dependency tree
- jspm allows you to configure arbitrary registries to get your dependencies from (github and npm are configured by default)
- even if jspm tracks module declaration and mapping, as well as configuration, into its own file (config.json), it actually defines the project dependencies inside the package.json (within the property jspm)
- you could use jspm packages either for a jspm project, or for a node / web project
- jspm is in fact just a package manager which wrap around the configuration system of SystemJs

So when you install a package from jspm it uses SystemJs configuration and set up the mapping between the dependencies, allowing you to export the project as any module types (AMD, CJS, esm, umd ...).


Are there any additional changes to be made if the package is installed using npm?

jspm install package makes a lookup in the jspm registry.
If no package is found, it means that you have to specify from which registry this package is coming from.

For an npm package it is: jspm install npm:package.
You can of course specify a specific version by appending @version at the end of the package name.

jspm also allows you to declare a shorthand to map this library within your code.

for more info see documentation: http://jspm.io/docs/installing-packages.html

like image 179
GBL Avatar answered Sep 22 '22 16:09

GBL


Both are package managers and essentially do the same function however here are some differences:

  • Npm will track packages in the package.json file whilst jspm will use the config.json file.
  • Npm will store it's packages in a node_modules folder whilst jspm will use a jspm_components folder.
  • Jspm is more commonly used to bring in client-side\front-end libraries and npm for server-side ones.

Restoring packages will normally follow like this:

  • Run npm install (should install jspm amongst other libraries)
  • Run jspm install
like image 35
Naeem Sarfraz Avatar answered Sep 22 '22 16:09

Naeem Sarfraz