Welcome!

@DevOpsSummit Authors: Pat Romanski, Yeshim Deniz, Liz McMillan, Elizabeth White, Zakia Bouachraoui

Related Topics: @DevOpsSummit, @CloudExpo

@DevOpsSummit: Blog Feed Post

Node.js ABC’s - N is for npm | @DevOpsSummit #Microservices

The Node Package Manager, also known as npm, is a software system that automates the process

Whether you are ready to start coding your first Node.js project, or if you are a seasoned veteran and need finish up a new exciting project, odds are you will need some functionality that has been written many times before by others.  One of the beauties of the internet is the ability to create and share things.  Node.js is a great language set in itself, but one key selling point is the vast amount of code that is available for free download.

The Node Package Manager, also known as npm, is a software system that automates the process of installing, upgrading, configuring, and removing Node.js packages.  As of Node.js version 0.6.3, npm is bundled and installed with the environment so once you have access to the node command line tools, you also have access to the vast number of shared packages available to you.

As of this writing, there are over 180,000 packages available in the npm.  You can find anything from credit card validators, to full language parsers.  If you have a task to perform, odds are there is a 3rd party package to help you along.  And the best feature I see is that packages are distributed as source script so you have full access to modify or extend the packages you pull from the repository.

npm

In my article on Loading, I discuss how you use the "require" command to load a module

Installing NPM

As I mentioned above, npm is included with Node.js versions 0.6.3 and above.  If you are using an older version of node, I'll leave it as an exercise to the reader to find the distribution package.  Better yet, I'd suggest upgrading to a more recent version of Node.js!

npm is itself distributed as a package through npm so you can have npm upgrade itself.  npm is updated quite frequently, so it's a good idea to upgrade npm once in a while

$ sudo npm install npm -g

Installing a package

Node.js has the concept of "local" and "global" packages.  Local packages are installed as part of your current project and are not available to other projects in your system.  Global packages are installed at the system level, so distributions that include command line tools (like npm) that you will want to use "globally", then you will want to include it in global scope.

Local Package Installation

To install a package locally, you'll use the "install" npm sub command.  Most often you will just need to specify the package name as an argument.

$ npm install package-name

Global Package Installation

To install a package globally, you'll use the "-g" argument.  Most often you will need to run this under "sudo" to allow for permissions in system folders.

$ sudo npm install -g package-name

Updating Packages

Since packages can be installed locally or globally, there is an update procedure for each as well.  Local updates are the easiest and can be completed with the "update" npm command.  This command will update all the packages in the local installation.

$npm update

To update packages globally, you add the "-g" option like you did above.

$npm update -g

But, in some cases you won't want to update all global packages at once.  You can use the "outdated" command to get a listing of global packages that need updating:

$ npm outdated -g --depth=0

and then you can update the global package with the same install command you used above

$ npm install -g package-name

Removing Packages

If the package you recently downloaded isn't living up to your expectations, you can use the "uninstall" npm command to remove the package from a local or global installation.  For a global installation, use the "-g" option as above

$ npm uninstall package-name
$ npm uninstall -g package-name

Creating Packages

In my article on Node.js Modules, I go over in detail the package creation process.  I'd suggest you read that article for details on creating your own package.

Publishing Packages

Once you have a great package put together, you may want to share that with the world.  The process for doing so is very easy.  You must first have a npm user account.  You can create a new user with the "npm adduser" command, or alternately login if you have an existing account with the "npm login" command.

Once you are authenticated, you can use the "publish" npm command to push your package to the npm repository.  use the folder name of your package in the "my-cool-package" parameter below:

$npm publish my-cool-package

Conclusion

Check out the Getting Started documentation on the npm website for more information on getting the most out of the Node Package Manager.

More Stories By Joe Pruitt

Joe Pruitt is a Principal Strategic Architect at F5 Networks working with Network and Software Architects to allow them to build network intelligence into their applications.

@DevOpsSummit Stories
You want to start your DevOps journey but where do you begin? Do you say DevOps loudly 5 times while looking in the mirror and it suddenly appears? Do you hire someone? Do you upskill your existing team? Here are some tips to help support your DevOps transformation. Conor Delanbanque has been involved with building & scaling teams in the DevOps space globally. He is the Head of DevOps Practice at MThree Consulting, a global technology consultancy. Conor founded the Future of DevOps Thought Leaders Debate. He regularly supports and sponsors Meetup groups such as DevOpsNYC and DockerNYC.
DXWorldEXPO LLC announced today that ICC-USA, a computer systems integrator and server manufacturing company focused on developing products and product appliances, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City. ICC is a computer systems integrator and server manufacturing company focused on developing products and product appliances to meet a wide range of computational needs for many industries. Their solutions provide benefits across many environments, such as datacenter deployment, HPC, workstations, storage networks and standalone server installations. ICC has been in business for over 23 years and their phenomenal range of clients include multinational corporations, universities, and small businesses.
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a member of the Society of Information Management (SIM) Atlanta Chapter. She received a Business and Economics degree with a minor in Computer Science from St. Andrews Presbyterian University (Laurinburg, North Carolina). She resides in metro-Atlanta (Georgia).
In his session at 20th Cloud Expo, Mike Johnston, an infrastructure engineer at Supergiant.io, discussed how to use Kubernetes to set up a SaaS infrastructure for your business. Mike Johnston is an infrastructure engineer at Supergiant.io with over 12 years of experience designing, deploying, and maintaining server and workstation infrastructure at all scales. He has experience with brick and mortar data centers as well as cloud providers like Digital Ocean, Amazon Web Services, and Rackspace. His expertise is in automating deployment, management, and problem resolution in these environments, allowing his teams to run large transactional applications with high availability and the speed the consumer demands.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.