All about npm

THERE IS SOMEONE WHO WORKS FOR NPM AND IT IS THEIR JOB TO HELP PEOPLE UNDERSTAND NPM BECAUSE IT IS SO FUCKING CONFUSING TO WHAT IT ACTUALLY DOES. LEARN JAVASCRIPT TOOLINGS AT YOUR OWN RISK. I DO NOT RECOMMEND IT BUT IT IS ALSO PRETTY MUCH NECESSARY TO LEARN AS OF LATE 2016. THERE IS ALSO THIS THING CALLED YARN.

ANYWAYS WOW… npm comes with node.js, so as long as you have node.js installed, you’re good to go. https://nodejs.org/en/ to dl

Check your npm version

$ npm -v

Upgrade your npm version to the latest version (note: this may take a while and you will receive very little feedback that it is actually doing anything)

$ npm install -g npm

Check version of an npm package globally

$ npm list -g babel

Check version of an npm package local

$ npm list
$ npm list <package_name>
$ npm list react

Get all possible versions available on NPM for a package

$ npm 

Find out where node modules are installed globally

$ npm root

Find out which packages are installed globally

$ npm list -g

Remove extraneous packages npm

$ npm prune

Create a new node.js project… at least I’m pretty sure that’s what this does…

$ npm init

Install a dependency for your application across development and production and update package.json (this is completely local to your project)

$ npm install react react-dom --save

Install a node package available for all npm projects (people recommend you do this sparingly)

$ npm install -g my-package

What the fuck is the difference between a dev-dependency and a dependency in package.json

Well, here’s a good resource. http://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies . The short answer is devDependencies are used to write code. They do stuff like compile and build code.

npm install –production will not install devDependencies.

NPM ERRORS or WARNINGS that I’ve experienced

ERROR: $ npm install npm WARN babel-loader@6.2.4 requires a peer of webpack@1 || ^2.1.0-beta but none was installed.

Yea, that makes absolutely no fucking sense. But… here’s the solution… Basically npm wants you to declare a peer dependency explicitly in your package.json (I had webpack installed globally). So to fix the error simply run.

Solution: $ npm i webpack –save-dev

npm stands for Node Package Manager. It manages node packages. A node package is like a gem, it’s a group of files that help you do something in coding. For instance, a node package could help you run a local development server. The babel node packages install es6 transpilers. The amount of node packages available on the web is astronomical. I don’t quite know exactly how everything fits together, so I ain’t gonna pretend like I’m speaking pure truth here. But, npm works with node.js. Node.js allows you to run a server that runs on javascript. This is cool because lots of people think it’s cool. I don’t think it’s that cool because node.js, npm, webpack, gulp and all that other front end bullshit is a lot to handle and digest.

Here’s what spawned node package manager (in my head, may have no relevance to any truth at all). People were developing all these packages for node. Sometimes when you create a package, it depends upon another package. A lot of times, you write some code, and you can use code from other people. But instead of asking you to figure out the dependencies yourself, node package manager does it for you! So node package manager really manages the dependencies of your application. I wish I could give you a concrete example, I mean, I could do that, but I don’t feel like it… so I’m going to be a shithole tutorial writer and not give you something that would actually really help you. This is what other tutorial writers do, they just don’t tell you they’re doing it. They aren’t technically lying to you because they didn’t say anything about being lazy, they just aren’t being forthcoming with the truth.

Post Content