npm i -S https://github.com/signalr/bower-signalr
Alternatively, you can target the commit responsible for making this possible via SHA as follows:
npm i -S https://github.com/signalr/bower-signalr.git#b46644962828760b0d5a0ee3c6f1dbf1fab4cc04
The approach described below still works as well.
Last Updated: 7/19/2016
Up the Creek Without a Paddle
The Life Raft
Step 1: Install napa locally as a development dependency:
npm i -D napa
Step 2: Configure napa in package.json:
In this gist, napa’s package caching feature is enabled; and, all cached packages installed via napa will be dumped into a .napa-cache folder at the same level as the package.json file. By the way, this .napa-cache folder should be barred from check-ins via an entry in a .tfignore, a .gitignore, or a similar file. Finally, the logging verbosity level is set to informational messages only.
Step 3: Define an npm script:
This “install” lifecycle event script was defined such that invoking the npm i command in step 5 below will run napa. We’re specifically requesting the tagged release of “v2.2.0” in this example. This script can now be invoked as a shortcut, thus eliminating the need to commit the lengthy napa command to memory.
Step 4: Install jQuery locally as a runtime dependency:
npm i -S firstname.lastname@example.org
Upon completion of this command, glance at the contents of your project’s node_modules folder. Within it, notice the new signalr folder. Its contents will mirror that of the corresponding GitHub repository, with the addition of a package.json file:
If you’ve followed along with the steps above, the completed package.json file for your project might resemble this:
This final step could be as straightforward as including a couple script tags on the page or as complex as using a module bundler, such as Webpack, to traverse the dependency tree and to decipher the necessary dependencies. Remember, the jquery.js file is located in the node_modules\jquery folder; and, the jquery.signalR.js file is located in the node_modules\signalr folder.
Even though SignalR was used as the example in this blog post, this approach can be adapted to virtually any open source project available on GitHub. The absence of a package.json file, which is inherent to npm packages, no longer poses a problem. Additionally, the napa options used here only scratch the surface. Refer to the project’s documentation for a complete rundown of features.