Installing packages in native windows node.js - windows

I am trying to get to grips with node.js, this looked like a fun tut http://net.tutsplus.com/tutorials/javascript-ajax/how-to-scrape-web-pages-with-node-js-and-jquery/ but I have only got the native windows version of node.js and I can't find a way to install any packages.
I have also looked at installing the binaries using chocalatey, but my version of vista doesn't have access to powershell. However, I do have a machine running windows 7 that I can switch to. If it isn't possible to install packages on windows version, I will switch to that machine and work through chocalatey.

Assuming you have the node.exe for Windows, npm has experimental support for windows. You can try working through the README.
Otherwise you can manually install packages on Windows. You will need to manually look at the package.json files for dependencies if you are going with option 2.
I have never tried it, but Scott Hanselman also has a post about getting node running on Windows.
Personally I have found its easier to just run a Linux VM since Windows support is kinda spotty right now.

The short answer is if you have git properly installed, you can open a cmd window, navigate to the directory containing node.exe, and run this:
git config --system http.sslcainfo /bin/curl-ca-bundle.crt
git clone --recursive git://github.com/isaacs/npm.git
cd npm
node cli.js install npm -gf
The more complete answer is that I posted a guide on how to install Node on Windows here. It also describes installing npm to manage packages. Let me know if it works for you.

Related

Is there a solution to install DRAKE on my WLS Ubuntu 18.04

I'm trying to install "Drake" (text-based data workflow tool) in a (WSL) Windows Subsystem for Linux and I try the steps in the book Data Science At The Command Line's Chapter 06 and the Drake's github repository I've followed all the steps without any problem, but when I try to install "Drip" github repository with this code
$ git clone https://github.com/flatland/drip.git
$ cd drip
$ make prefix=~/bin install
I had this :
I desperately tried a few things like adjusting the java's environment variables for my windows system and in my WSL Ubuntu too, without success
My Windows Build is :
And my WSL is:
My problem was to install "DRAKE" a Data workflow tool, after being searching for a solution I heard about Homebrew a solution made initially for installing tools on macOS and it's available now for linux even for WSL!
like in magic just type the tool to install and it's automatically done even if it's requires dependencies
brew install drake
So for nubies like me it's a welcome tool which can save you a lot of time.

Ugly output when running NPM commands from Windows

I have manually installed "node.exe" (0.10.36 x64) & NPM Zip (1.4.12) under Windows 7.
When I run a NPM command (from cmd, powershell or Eclipse TCF terminals), it prints a lot of a new line with single character from this list: -\|/.
However, it doesn't with Eclipse console.
It uselessly fills the console and makes difficult to see messages, especially when running some infinite running command like "karma start".
Is there any way to remove/fix these ugly output characters ?
It's an issue of "1.4.12" and "1.4.13" versions. Switch back to 1.4.10 (1.4.11 doesn't work at all on my computer) has solved the issue.
Another solution can be to upgrade to newer versions of npm simply running npm install npm --global. If want to easy switch NPM versions, just copy "npm.cmd" and "node_modules/npm" to another directory. Then from this directory, run npm install npm. Finally, update your PATH to take this directory in priority (or remove the old npm versions).
I have the same issue on Win 10. I was previously using v0.12.7 (I did not know why I used a so "old" version) then installed v4.2.2 which makes ugly output.
To solve this problem, I uninstalled v4.2.2 from Control Panel, removed npm and npm_cache folder from %APPDATA%, and finally removed all paths related to Node and npm from PATH environment variable.
Hope this could help someone.

How do I update npm on Windows?

When I install node 0.10.33 from the msi ( http://nodejs.org/download/ ), I get an old version of npm (1.4.28). How can I upgrade npm on Windows?
npm install -g npm
does not work; I still have the old npm.
You need to follow the Windows upgrade instructions ( https://docs.npmjs.com/try-the-latest-stable-version-of-npm )
tl;dr - npm -g install npm does work, but the old version of npm is still in your PATH.
To fix this, do one of these:
Option 2: remove both of
C:\Program Files (x86)\nodejs\npm
C:\Program Files (x86)\nodejs\npm.cmd
Or
Option 3: Open cmd.exe as administrator, navigate to C:\Program Files (x86)\nodejs and
then run the installation without -g:
npm install npm#latest
*There is an npm package that automate this Option 3:
npm install -g npm-win-upgrade
We at Microsoft Open Source wrote a small tool to automate the process outlined above. You can find it here or just install and run it by executing the following in an elevated command prompt / PowerShell:
npm install -g npm-windows-upgrade
npm-windows-upgrade
There May be many ways to update your npm in Windows
Way 1
Open you power shell as Administrator and run following commands step by step.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
Here you can select your preferred version of npm
Ready to go !
Way 2
You can simply upgrade to the latest npm version with following command
npm install npm#latest -g
or if you want a specific version of npm simply run
npm install npm#{version} -g for example npm install npm#3.3.12 -g
Now simply run npm --version or npm -v to know your current version of npm
3.3.12 is my preferred version of npm that best suits for approximately every package.
UPDATE
npm install npm#latest -g
the correct npm version is now already shipped with node.js so you can directly switch node version.
you can nvm (Node Version Manager) package to switch node versions very quick and easy.
So, TL;DR; this worked:
Uninstall node
From a command prompt, run where npm
If you had npm installed via chocolatey, you'll see a path like C:\ProgramData\chocolatey\bin\npm.exe - DELETE it!
Now install NodeJS using the appropriate MSI from https://nodejs.org/en/download/
In your favourite shell, type npm --version - this should now echo the version of NPM that came with NodeJS (at the time of this writing, that version is 3.10.10)
This is what worked for me (goofy me!)
I had (age ago) installed npm via chocolatey, which created a chocolatey initiated npm.exe in C:\ProgramData\chocolatey\bin\npm.exe. This was npm version 1.4.9 and wouldn't update no matter what one did including uninstall and reinstall NodeJs.
=======
EDIT: Better way to install node and npm
As of today (27/06/2017), the best way to install and manage node and npm is to install nvm (Node Version Manager) as explained here: https://github.com/coreybutler/nvm-windows. Once you have nvm, installing any node version is super easy:
Open your favourite console (CMD, Cmder, PowerShell)
Type nvm install 6.10.2 (to install node version 6.10.2)
To see the currently active version, type nvm list. This prints something like below:
6.9.3
* 6.9.2 (Currently using 64-bit executable)
6.9.1
6.10.2
It's late 2021 and a lot of these answers can be confusing. npm install -g npm can break your installation. (When I did this, I had to run the Node MSI "Repair" tool to get it working again.) npm-windows-upgrade has not seen a release in over 2 years, and the repo has been archived by its maintainer.
As far as I can tell, there are two options that seem to work reliably today.
Use where npm from DOS prompt or which npm from WSL / Git Bash / etc, to determine which NPM binary is being used.
cd to that path, then run npm install npm#latest (without the -g flag!). npm update npm should have the same effect. You may need an elevated prompt (Run As Administrator).
Verify that this worked by running npm --version.
This worked for me. The other option is:
Completely uninstall NPM + Node using the Add/Remove Programs settings page.
Install an MSI from the Node website.
To upgrade NPM on windows 10
Uninstall Node.js
Restart your system
on command prompt type where npm
delete if npm and npm-cache folder exists in AppData/Roaming
Install Node.js (https://nodejs.org/en/)
You need to follow the Windows upgrade instructions
https://www.npmjs.com/package/npm-windows-upgrade
First, ensure that you can execute scripts on your system by running the following command from an elevated PowerShell. To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install --global --production npm-windows-upgrade
npm-windows-upgrade
Want to just install the latest version?
1.npm-windows-upgrade --npm-version latest
I did something similar to Sam Mikes. I'm only sharing this because I couldn't get either of his solutions to work on my rig. After a bit of playing around, this is what worked for me:
Remove NPM/Node from your Environment Variables, both for user and system.
Close your open console if you have one open, then open a console as administrator
Change directories to %USERPROFILE% -- that's a window's environment variable that takes you to C:\Users\CurrentlyLoggedInUser
Run from the console in %USERPROFILE%, "C:\Program Files\nodejs\npm" install npm -g (you might have yours in the x86 folder)
If this solution would work for you, step 4 would have worked, and npm -v will show a an up-to-date version
Re-add Node (in Program Files)/NPM (in App Data -- the one installed in Program Files should be the old one) to your user and system environment variables
Note: I've used the Microsoft automated script in the past to fix this, but only because I didn't realize how easy it would be to do it myself.
So none of the previous answers solved the issue for me so I thought I would post my specific solution, which I managed to figure out by going through all the other answers so they were really helpful.
My issue was because I had used chocolatey to install node and possibly npm (looking at chocolatey site now I shouldn't have done that).
To solve the issue I simply had to run the relevant choco uninstall commands for npm and node and then everything switched to the other version of node which I had also installed using the node msi (from node's website).
I hope that helps anyone else that may have gone down the same path as me.
I tried almost every answer but none of them works my way.
Neither npm-windows-upgrade worked nor did the npm install npm#latest etc etc worked.
For people like me I will suggest you guys downloading the latest installer from Node.js website, let the existing version of node directory be on it's place and without changing anything just install the msi installer and you will end up with an upgraded version of node.
My case was upgrading node from 6 to 8.9.3
all npm install commands were getting stuck and will throw error (behind proxy error) after sometime. setting up proxy was not helping. This is what I did.
Had 8.11 nodeJS
Uninstalled NodeJS from Programs & Features with the uninstaller.
Reboot (or you probably can get away with killing all node-related processes from Task Manager).
Look for these folders and remove them (and their contents) if any still exist. Depending on the version you installed, UAC settings, and CPU architecture, these may or may not exist:
• C:\Program Files (x86)\Nodejs
• C:\Program Files\Nodejs
• C:\Users{User}\AppData\Roaming\npm (or %appdata%\npm)
• C:\Users{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
• C:\Users{User}.npmrc (and possibly check for that without the . prefix too)
Check your %PATH% environment variable to ensure no references to Nodejs or npm exist.
If it's still not uninstalled, type where node at the command prompt and you'll see where it resides -- delete that (and probably the parent directory) too.
Reboot, for good measure.
Installed 6.11 nodejs then it worked.
Use npm-windows-upgrade tool to simply upgrade. Steps are provided in the link.
For update node npm on Windows
I have to delete node in:
C:\Users**YOUR USER**\AppData\Roaming
And reinstall node

cannot install npm in MacBook Pro

My laptop cannot run the command 'npm' now.
I work in a group for my coursework using Node.js plus Express.
first time, I installed the node.js and express in my laptop. One of group member put application package on the Git and I just need to connect with the Git and not necessary to install Node and Express individually. So I tried to connect with Git with commands; $git pull, and install package with $ npm install, it works well.
Then, I deleted Node.js and Express files in my local driver in the laptop, and connect with Git using the same codes above, whilst $npm doesn't work as well. The error always is 'command not find'. help!!!!
Git and NPM are unrelated however you may be using them both for your project. Git is a version control system and NPM is a Package Manager for Node.js
Reinstall Node.js (NPM comes with it too by default) from http://nodejs.org/

Node.js + Socket.io + Windows 7 / 8?

I've been searching everywhere, but can't seem to find a solution. Is it possible to install Socket.io on Node.js on Windows 7?
If not, is there some sort of alternative, or do you know of any future Windows support?
Usually the Node.js package manager is used, however I can't find a way of installing that on Windows. http://npmjs.org/
I'm currently using Node.exe (not running it through Cygwin).
This is how I'd imagine it would be installed on Windows, if NPM worked:
npm install socket.io
Node Package Manager now works on Windows 7
Simply install Node.js and type npm install socket.io into the Windows console and look in C:\Users\[insert username]\node_modules.
I am confirming that npm install socket.io works perfectly with Node.js 0.6.10 on Windows 7 (remember to run cmd as Administrator).
For anyone who is having trouble getting Node.js and socket.io working on Windows...
There is the nodejs-win project on Google Code.
http://code.google.com/p/nodejs-win/downloads/detail?name=node_setup_0.5.6.7.exe&can=2&q=
And here is a video that shows the basics of using it.
Node.JS & Socket.IO Chat System in Windows
Now that Node.js version 0.6.0 is available, and it seems pretty stable so far, I'm going to suggest using it if you're planning on developing on Windows.
http://nodejs.org/download/
Either use a Linux box or git clone the socket.io repository and require it from a local path.
You will have to copy the entire socket.io library into, for example, lib/socket.io/
Then var io = require("./lib/socket.io/index.js
npm runs on Node.js. If you are having problems running npm, then you should also be having problems with Node.js. Assuming you are running Node.js through Cygwin, then you should be able to run
node npm install socket.io
(Which is the same as npm install socket.io)
Also.
Npm is just the Node.js package manager. There is nothing that it provides that you can't get from the repositories themselves. It is just, for obvious reasons, a lot easier to use npm.
If you want the socket.io included, then just create a node_modules directory inside of your /lib directory or wherever your project is, and then clone the socket.io to it.
https://github.com/LearnBoost/socket.io
Edit
The OP indicated that he is using node.exe. There is no way currently as of 1st September 2011 to use npm with node.exe. It is currently on the node.exe roadmap and will hopefully be completed soon, but not as of today.
(Check the mailing list if you want to be updated).
Since the 0.6.6 version (as far as I remember) Node.js has a normal version for Windows, and after installing it a npm.exe file appears in the install directory, not sure how exactly I was running it, maybe something like node npm install socket.io.
Or maybe npm install socket.io. If none of these works, try to execute npm by typing full path to it (unless you have added a system variable for the path). For the record - I have successfully installed sokcet.io on Windows 7 via npm :)
Until NPM is built for Windows you'll need to download the packages manually and create the node_modules folder structure in the node.exe folder. Follow this post.
For me, downloading the modules directly from GitHub and putting them in the "node_modules" directory works. AFAIK that's what npm does. It works both if you put it in your user directory, or in the same directory as node.exe.
Too bad there's no Windows port for npm, since there's almost no porting needed to be done, and that node comes as a stand-alone executable instead of an installer, like Python.
I faced the same problem and edited the Socket.IO library to work on windows. Details of the same you can find here.
I had the same problem with Node.js v10.22 on Windows 7 - this worked for me:
npm install socket.io#0.8.4
Create a file called package.json in your project directory with the following.
{
"name": "project name",
"description": "project description,
"version": "0.0.1",
"dependencies": {
"express": "2.4.6",
"socket.io": "version"
}
}
Then run the npm install

Resources