Skip to content

Instantly share code, notes, and snippets.

@jsagardoy
Last active April 25, 2018 14:45
Show Gist options
  • Save jsagardoy/b8b37b9060e594a3575b8a0d7a92ba05 to your computer and use it in GitHub Desktop.
Save jsagardoy/b8b37b9060e594a3575b8a0d7a92ba05 to your computer and use it in GitHub Desktop.
Summary of useful npm commands

npm command list

This gists is just a compendium of usefull NPM commands commonly used in different languages.

npm init

This will ask you a bunch of questions, and then write a package.json for you.

It attempts to make reasonable guesses about what you want things to be set to, and then writes a package.json file with the options you've selected.

If you already have a package.json file, it'll read that first, and default to the options in there.

It is strictly additive, so it does not delete options from your package.json without a really good reason to do so.

Documentation

npm init

If you invoke it with -f, --force, -y, or --yes, it will use only defaults and not prompt you for any options npm init -y.

For naming ralated, try avoiding blank spaces and not defining your proyect as "React".

npm webpack

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

Documentation

npm i webpack

npm webpack-cli

Webpack CLI encapsulates all code related to CLI handling. It captures options and sends them to webpack compiler. You can also find functionality for initializing a project and migrating between versions.

Documentation

npm i webpack-cli

npm webpack-dev-server

[Development only] This commmand will install a webpack deverloper server that provides live reloading.

Should be installed under --save-dev

Documentation

npm i webpack-dev-server -D

npm css-loader

The css-loader interprets @import and url() like import/require() and will resolve them.

Documentation

Should be installed under --save-dev

npm i css-loader -D

npm style-loader

Adds CSS to the DOM by injecting a <style> tag

It's recommended to combine style-loader with the css-loader

Documentation

Should be installed under --save-dev

npm i style-loader -D

npm file-loader

Instructs webpack to emit the required object as file and to return its public URL.

Documentation

Should be installed under --save-dev

npm i file-loader -D

npm url-loader

Loads files as base64 encoded URL.

Documentation

Should be installed under --save-dev

npm i url-loader -D

npm html-webpack-plugin

Plugin that simplifies creation of HTML files to serve your bundles.

Documentation

Should be installed under --save-dev

npm i html-webpack-plugin -D

npm awesome-typescript-loader

Awesome-typescript-loader loader was created mostly to speed-up compilation.

Documentation

Should be installed under --save-dev

npm i awesome-typescript-loader -D

npm mini-css-extract-plugin

This plugin extract CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS and SourceMaps.

It builds on top of a new webpack v4 feature (module types) and requires webpack 4 to work.

Documentation

Should be installed under --save-dev

npm i mini-css-extract-plugin -D

npm typescript

TypeScript is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the playground, and stay up to date via our blog and Twitter account.

Documentation

Should be installed under --save-dev

npm i typescript -D

npm babel-core

Babel compiler core

Documentation

Should be installed under --save-dev

npm i babel-core -D

npm babel-preset-env

A Babel preset that compiles ES2015+ down to ES5 by automatically determining the Babel plugins and polyfills you need based on your targeted browser or runtime environments.

Documentation

Should be installed under --save-dev

npm i babel-preset-env -D

npm bootstrap

Sleek, intuitive, and powerful front-end framework for faster and easier web development

Documentation

Should be installed for production matters under -dev

npm i bootstrap -P

React

react

An npm package to get you immediate access to React, without also requiring the JSX transformer. This is especially useful for cases where you want to browserify your module using React.

By default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages. To use React in production mode, set the environment variable NODE_ENV to production. A minifier that performs dead-code elimination such as UglifyJS is recommended to completely remove the extra code present in development mode.

Documentation

npm i react -P

react-dom

This package serves as the entry point of the DOM-related rendering paths. It is intended to be paired with the isomorphic React, which will be shipped as react to npm.

Documentation

npm i react-dom -P

@types/react

This package contains type definitions for React (http://facebook.github.io/react/).

Documentation

npm i @types/react -P

@types/react-dom

This package contains type definitions for React (react-dom) (http://facebook.github.io/react/).

Documentation

npm i @types/react-dom -P

React-router-dom

Package router for React

Documentation

npm i react-router-dom -P

@types/React-router-dom

This package contains type definitions for React Router (https://github.com/ReactTraining/react-router).

Documentation

npm i @types/react-router-dom -D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment