Node.js and npm for the Windows Developer

Download this episode

Download Video

Download captions

Download Captions

Description

Learn best practices for Node.js with Visual Studio and Windows, including how and why to use npm packages and modules. Highlights include:

[3:28]- Helloworld in node

[6:26]- Bobblehead Generator!

[11:40]- Your max path woes destroyed

[17:07]- Back to Bobbleheads

[25:38]- C++ in Node.js errors demystified

[30:28]- deploying your app

[40:18]- You don't know npm

[43:53]- what you may not know about npm(npm init)

[46:23]- npm global cache

[47:33]- npm shrinkwrap

[49:45]- npm versioning and run scripts

[51:49]- npm lifecycle events

[53:19]- npm scoped packages

 

Microsoft + Node.js guidelines found here

npm documentation found here

 

SPEAKERS

Visual Studio with npm and Node.JS (Sarah Itani – Microsoft) 

npm Scoped Packages (Ashley Williams – npm, Inc.) 

 

 

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      LukePuplett

      My story:

      I'm currently working at a gig using npm, grunt, bower and friends on a large Angular app + WebAPI.

      The front-end guys were Mac-based originally with some PC + VS2013 experience working remotely. They wrote the gruntfile and package.json etc.

      The project has never built on the dev-team's machines. We're all on Windows, AD, group policies and proxy and firewall rules in a financial company.

      We've had the max_path issue, we've continue to have proxy problems, but even with latest npm and using dedupe and being routed directly out to the web, we have issues just with npm package installations failing on "npm install" for reasons we cannot reasonably debug.

      We've so far not been able to get automated build working for the front-end/site. This is obviously a problem for continuous integration and testing.

      I would recommend treading very cautiously if you are to embark on a greenfield website on Windows and are mulling the use of these Linux/Mac technologies.

      I think a major problem is that there are so few people consuming these tools and the packages from Windows that bugs are not found and there's a lack of interest in resolving them for such a small number of "Microsoft" devs.

      Limit the amount of packages you use in the first place. Potentially have the front-end devs have their own gruntfile + packages.json

      I also recommend checking the packages into source control and avoiding "npm install" once you have successfully cached the node_modules locally and deduped to a point where they're all <max_path, else the installers could just stop working at some future point.

      Btw, I had to install Cntlm local proxy to get this to work and even then, some packages seem to call git in such a way that git ignores its own proxy settings. It's hard going and, to my mind, with the features in VS, not really winning us anything yet except that we could work with a "cooler" digital agency for the front-end who like to use Mac.

    • User profile image
      CareBear

      @LukePuplett: Working on a large Angular app as well, and have used both grunt and gulp extensively before. I do have some experience with issues that have been caused by problems during download and unpacking of the npm packages, but they have all been fixed with a cache clean and retries. Many great improvements with npm 3 which is now included with NodeJS 4 and 5.

      So I don't think there is any point in telling others to be "treading very cautiously", that could scare most people away. Microsoft have added support for using npm in both Cordova Apps and in the upcoming ASP.NET 5 projects, as well as Bower (I don't advice anyone to use it, rely only on npm if possible).

      And if someone is reading this, you should not take the advice of checking the node_modules into your source control. Depending on what you are working on, you might be commiting tens of thousands of files with a total size of potentially hundreds of megabytes. We use npm for both gulp tasks and for app client libs, so it's a lot of files. Having those in the source repository would be detrimental to any project, and horrible during updates and upgrades for individual developers.

      While Node.JS did not start out on the Windows platform, it has matured a lot in the recent time and is getting widespread use for both client and server based solutions.

      One important tip: Always use specific version number in package.json, or else you might introduce bugs in production and test environments that you don't have on local machines.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.