How to install node js windows 10
How to install node js windows 10
Tutorial: Node.js for Beginners
If you’re brand new to using Node.js, this guide will help you to get started with some basics.
Prerequisites
If you are a beginner, trying Node.js for the first time, we recommend installing directly on Windows. For more information, see Should I install Node.js on Windows or Windows Subsystem for Linux
Try NodeJS with Visual Studio Code
If you have not yet installed Visual Studio Code, return to the prerequisite section above and follow the installation steps linked for Windows or WSL.
Create a JavaScript file named «app.js» with a variable named «msg» inside: echo var msg > app.js
Add a simple string variable («Hello World»), then send the contents of the string to your console by entering this in your «app.js» file:
To run your «app.js» file with Node.js. Open your terminal right inside VS Code by selecting View > Terminal (or select Ctrl+`, using the backtick character). If you need to change the default terminal, select the dropdown menu and choose Select Default Shell.
Notice that when you type console in your ‘app.js’ file, VS Code displays supported options related to the console object for you to choose from using IntelliSense. Try experimenting with Intellisense using other JavaScript objects.
Create your first NodeJS web app using Express
Express is a minimal, flexible, and streamlined Node.js framework that makes it easier to develop a web app that can handle multiple types of requests, like GET, PUT, POST, and DELETE. Express comes with an application generator that will automatically create a file architecture for your app.
To create a project with Express.js:
Open your command line (Command Prompt, Powershell, or whatever you prefer).
Create a new project folder: mkdir ExpressProjects and enter that directory: cd ExpressProjects
The files that Express generates will create a web app that uses an architecture that can appear a little overwhelming at first. You’ll see in your VS Code Explorer window (Ctrl+Shift+E to view) that the following files and folders have been generated:
You now need to install the dependencies that Express uses in order to build and run your HelloWorld Express app (the packages used for tasks like running the server, as defined in the package.json file). Inside VS Code, open your terminal by selecting View > Terminal (or select Ctrl+`, using the backtick character), be sure that you’re still in the ‘HelloWorld’ project directory. Install the Express package dependencies with:
At this point you have the framework set up for a multiple-page web app that has access to a large variety of APIs and HTTP utility methods and middleware, making it easier to create a robust API. Start the Express app on a virtual server by entering:
The DEBUG=myapp:* part of the command above means you are telling Node.js that you want to turn on logging for debugging purposes. Remember to replace ‘myapp’ with your app name. You can find your app name in the package.json file under the «name» property. Using npx cross-env sets the DEBUG environment variable in any terminal, but you can also set it with your terminal specific way. The npm start command is telling npm to run the scripts in your package.json file.
You can now view the running app by opening a web browser and going to: localhost:3000
Now that your HelloWorld Express app is running locally in your browser, try making a change by opening the ‘views’ folder in your project directory and selecting the ‘index.pug’ file. Once open, change h1= title to h1= «Hello World!» and selecting Save (Ctrl+S). View your change by refreshing the localhost:3000 URL on your web browser.
To stop running your Express app, in your terminal, enter: Ctrl+C
Try using a Node.js module
Node.js has tools to help you develop server-side web apps, some built in and many more available via npm. These modules can help with many tasks:
Tool | Used for |
---|---|
gm, sharp | Image manipulation, including editing, resizing, compression, and so on, directly in your JavaScript code |
PDFKit | PDF generation |
validator.js | String validation |
imagemin, UglifyJS2 | Minification |
spritesmith | Sprite sheet generation |
winston | Logging |
commander.js | Creating command-line applications |
Let’s use the built-in OS module to get some information about your computer’s operating system:
Install NodeJS on Windows
If you are new to developing with Node.js and want to get up and running quickly so that you can learn, follow the steps below to install Node.js directly on Windows.
If you are using Node.js professionally, find performance speed and system call compatibility important, want to run Docker containers that leverage Linux workspaces and avoid having to maintain both Linux and Windows build scripts, or just prefer using a Bash command line, then install Node.js on Windows Subsystem for Linux (more specifically, WSL 2).
Install nvm-windows, node.js, and npm
Besides choosing whether to install on Windows or WSL, there are additional choices to make when installing Node.js. We recommend using a version manager as versions change very quickly. You will likely need to switch between multiple Node.js versions based on the needs of different projects you’re working on. Node Version Manager, more commonly called nvm, is the most popular way to install multiple versions of Node.js, but is only available for Mac/Linux and not supported on Windows. Instead, we recommend installing nvm-windows and then using it to install Node.js and Node Package Manager (npm). There are alternative version managers to consider as well covered in the next section.
It is always recommended to remove any existing installations of Node.js or npm from your operating system before installing a version manager as the different types of installation can lead to strange and confusing conflicts. This includes deleting any existing nodejs installation directories (e.g., «C:\Program Files\nodejs») that might remain. NVM’s generated symlink will not overwrite an existing (even empty) installation directory. For help with removing previous installations, see How to completely remove node.js from Windows.)
Follow the install instructions on the windows-nvm repository. We recommend using the installer, but if you have a more advanced understanding of your needs, you may want to consider the manual installation. The installer will point you to the releases page for the most recent version.
Download the nvm-setup.zip file for the most recent release.
Once downloaded, open the zip file, then open the nvm-setup.exe file.
The Setup-NVM-for-Windows installation wizard will walk you through the setup steps, including choosing the directory where both nvm-windows and Node.js will be installed.
Once the installation is complete. Open PowerShell (recommend opening with elevated Admin permissions) and try using windows-nvm to list which versions of Node are currently installed (should be none at this point): nvm ls
Install the current release of Node.js (for testing the newest feature improvements, but more likely to have issues than the LTS version): nvm install latest
After installing the Node.js version numbers you need, select the version that you would like to use by entering: nvm use (replacing with the number, ie: nvm use 12.9.0 ).
Alternative version managers
While windows-nvm is currently the most popular version manager for node, there are alternatives to consider:
nvs (Node Version Switcher) is a cross-platform nvm alternative with the ability to integrate with VS Code.
Volta is a new version manager from the LinkedIn team that claims improved speed and cross-platform support.
To install Volta as your version manager (rather than windows-nvm), go to the Windows Installation section of their Getting Started guide, then download and run their Windows installer, following the setup instructions.
You must ensure that Developer Mode is enabled on your Windows machine before installing Volta.
To learn more about using Volta to install multiple versions of Node.js on Windows, see the Volta Docs.
Install Visual Studio Code
We recommend you install Visual Studio Code, as well as the Node.js Extension Pack, for developing with Node.js on Windows. Install them all or pick and choose which seem the most useful to you.
To install the Node.js extension pack:
A few additional extensions you may want to consider include:
Alternative code editors
If you prefer to use a code editor or IDE other than Visual Studio Code, the following are also good options for your Node.js development environment:
Install Git
If you plan to collaborate with others, or host your project on an open-source site (like GitHub), VS Code supports version control with Git. The Source Control tab in VS Code tracks all of your changes and has common Git commands (add, commit, push, pull) built right into the UI. You first need to install Git to power the Source Control panel.
Download and install Git for Windows from the git-scm website.
An Install Wizard is included that will ask you a series of questions about settings for your Git installation. We recommend using all of the default settings, unless you have a specific reason for changing something.
If you’ve never worked with Git before, GitHub Guides can help you get started.
How to Install Node.js on Windows 10 [4 Steps]
Table of Contents
Node.js is free and an open-source cross-platform JavaScript run-time environment that allows server-side execution of JavaScript code. It is used in developing web and networking applications
NPM (Node Package Manager) is command line tool for Node.js packages that installs, updates and uninstall packages in your projects.We don’t have install npm separately it is includes with Node.js installation.
Prerequisite
Step #1: Download Node.js package for Windows
Click on 32 bit or 64 bit version of node.js for windows.
once you clicked, it will ask for to save dowloaded node.js msi setup, click on Save File.
click on Node.js License agreement and click on Next.
Select Destination folder where you want to Install Node.js and click on Next.
Select on to install npm modules like python and Visual Studio Build Tools if not installed and click on Next
custom setup for Node.js and click on Next.
Step #2: Install Node.js on Windows
Now Install Node.js on Windows 10, click on Install.
wait to finish to Install Node.js on Windows.
once installing of Node.js finished, click on Finish.
It will open commands prompt to Install Addition Tools for Node.js for Windows, click Enter.
once you entered, it will open Windows Powers shell and wait till to Install additional Tools for Node.js.
Check Node.js and npm version on Windows.
Note: when you install node.js using msi installed, you don’t need to setup system variables for node.js.
Step #3: How to Update Node.js and NPM on Windows
OR
open a commands prompt and run below commands to update the node.js and npm on windows
Output:
Step #4: Create a Node.js Application on Windows
Create a javascript file with name nodeapp.js in C:\Users\your name\ location, add below code which prints ” Hello World”.
Paste the below lines into it.
Run your Node.js server with the below command,
Output:
Now open your browser and type server name or IP followed by port 3000, you will see Hello World message.
you will see “Hello World” Message on your browser.
How to Uninstall/Remove Node.js and NPM from Windows
To Uninstall or completely Remove Node.js and NPM from Windows 10.
1. Open the Control Panel
2. click on Programs and Features
3. Select Node.js
4. click on Uninstall Button
It will ask to confirm uninstall node.js from Windows.
Conclusion:
In this article, We have performed, Download Node.js for Windows, How to Install Node.js on Windows 10, update the node.js and npm on windows, creating node.js app on windows, running and testing node.js app, uninstalling node.js from windows 10.
Related Articles
Sharing is Caring:
FOSS TechNix
FOSS TechNix (Free,Open Source Software’s and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.
Установка Node.js в Windows
Если вы не занимались разработкой с помощью Node.js и хотите быстро начать работу, установите Node.js непосредственно в Windows, выполнив указанные ниже действия.
Если вы используете Node.js профессионально и вам нужно оптимизировать скорость и производительность, обеспечить совместимость системных вызовов, выполнять контейнеры Docker, которые используют рабочие области Linux, и не нужно использовать скрипты сборки Linux и Windows или вы просто предпочитаете использовать командную строку Bash, установите Node.js в подсистеме Windows для Linux (точнее, в WSL 2).
Установка nvm-windows, Node.js и npm
Наряду с возможностью выбора системы для разработки (Windows или WSL) при установке Node.js доступны и другие возможности. Мы рекомендуем использовать диспетчер версий, так как версии меняются достаточно быстро. Вероятно, вам придется переключаться между несколькими версиями Node.js в зависимости от потребностей для различных проектов, над которыми вы работаете. Диспетчер версий Node Version Manager, чаще называемый nvm, является наиболее популярным средством установки нескольких версий Node.js, но он доступен только для Mac и Linux и не поддерживается в Windows. Вместо этого мы рекомендуем установить средство nvm-windows, а затем с его помощью установить Node.js и диспетчер Node Package Manager (npm). Существуют также альтернативные диспетчеры версий, которые описаны в следующем разделе.
Рекомендуем всегда удалять любые имеющиеся установки Node.js или npm из операционной системы перед установкой диспетчера версий, так как эти установки могут создавать необычные и запутанные конфликты. Сюда относится удаление всех существующих каталогов установки Node.js (например, C:\Program Files\nodejs), которые могут остаться. Созданная символьная ссылка NVM не будет перезаписывать существующий (даже пустой) каталог установки. Справку по полному удалению предыдущих установок см. здесь.
Следуйте инструкциям по установке, приведенным в репозитории windows-nvm. Мы рекомендуем использовать установщик, но если вы лучше понимаете свои потребности, возможно, целесообразным будет выполнить установку вручную. Установщик перенаправит вас на страницу выпусков с информацией о последней версии.
Скачайте последний выпуск файла nvm-setup.zip.
После скачивания откройте ZIP-файл, а затем запустите файл nvm-setup.exe.
Мастер установки Setup-NVM-for-Windows поможет выполнить все этапы установки, в том числе выбрать каталог, в котором будут установлены репозиторий nvm-windows и Node.js.
Установка завершится. Откройте PowerShell (рекомендуется открыть с повышенными правами администратора) и попробуйте использовать windows-nvm, чтобы указать, какие версии узла сейчас установлены (на этом этапе они не указаны): nvm ls
После установки требуемых версий Node.js выберите нужную версию, введя nvm use (замените нужным номером, например nvm use 12.9.0 ).
Альтернативные диспетчеры версий
Несмотря на то что windows-nvm сейчас является самым популярным менеджером версий для Node, есть несколько альтернативных вариантов:
nvs (Node Version Switcher) — это кроссплатформенный вариант nvm с возможностью интеграции с VS Code.
Volta — это новый диспетчер версий, созданный командой LinkedIn. Заявлено, что он отличается увеличенной скоростью и межплатформенной поддержкой.
Чтобы установить Volta в качестве диспетчера версий (вместо windows-nvm), перейдите в раздел Установка Windows руководства Начало работы, затем скачайте и запустите установщик Windows, следуя инструкциям.
Перед установкой Volta необходимо убедиться, что на компьютере с Windows включен режим разработчика.
Дополнительные сведения об использовании Volta для установки нескольких версий Node.js в Windows см. в документации по работе с Volta.
Установка Visual Studio Code
Для разработки с помощью Node.js в Windows рекомендуем установить Visual Studio Code, а также пакет расширений Node.js. Установите их все или выберите наиболее полезные для вас.
Чтобы установить пакет расширений Node.js, сделайте следующее:
К дополнительным рекомендуемым расширениям относятся следующие:
Альтернативные редакторы кода
Если вы предпочитаете использовать редактор кода или интегрированную среду разработки, отличные от Visual Studio Code, для среды разработки Node.js также подходят следующие варианты:
Установка GIT
Если вы планируете работать совместно с другими пользователями или размещать проект на сайте с открытым исходным кодом (например, GitHub), примите во внимание, что VS Code поддерживает управление версиями с помощью Git. Вкладка системы управления версиями в VS Code отслеживает все изменения и содержит общие команды Git (добавление, фиксация, принудительная отправка, извлечение) прямо в пользовательском интерфейсе. Сначала необходимо установить Git для включения панели управления версиями.
Скачайте и установите Git для Windows с веб-сайта git-scm.
В комплект входит мастер установки, который задает вам ряд вопросов о параметрах установки Git. Рекомендуется использовать все параметры по умолчанию, если у вас нет конкретной причины изменить какой-либо из них.
Если вы никогда не использовали Git, обратитесь к руководствам по GitHub. Они помогут вам приступить к работе.
LearnHow to Install Node.js® and NPM on Windows [Guide]
Dave McFarland
writes on January 7, 2015
JavaScript is quickly becoming the go-to language for web developers. Front-end web developers use JavaScript to add user interface enhancements, add interactivity, and talk to back-end web services using AJAX. Web developers who work on the server-side are also flocking to JavaScript because of the efficiencies and speed offered by JavaScript’s event-driven, non-blocking nature.
In fact, concentrating on JavaScript as your language of choice offers the opportunity to master a single language while still being able to develop “full-stack” web applications.
In a previous article, I wrote about how to install Node.js® and, it’s companion, NPM on a Mac. Fortunately, for Windows users, the Node.js® installation process is a lot easier than how I recommend installing Node.js® on a Mac.
What is the Difference Between Node & NMP?
The key to this server-side JavaScript revolution is Node.js® — a version of Chrome’s V8 JavaScript runtime engine — which makes it possible to run JavaScript on the server-side.
Node.js is also used for developing desktop applications and for deploying tools that make developing web sites simpler. For example, by installing Node.js® on your desktop machine, you can quickly convert CoffeeScript to JavaScript, SASS to CSS, and shrink the size of your HTML, JavaScript and graphic files. Using NPM — a tool that makes installing and managing Node modules — it’s quite easy to add many useful tools to your web development toolkit.
When to use Node
Node isn’t a program that you simply launch like Word or Photoshop: you won’t find it pinned to the taskbar or in your list of Apps. To use Node you must type command-line instructions, so you need to be comfortable with (or at least know how to start) a command-line tool like the Windows Command Prompt, PowerShell, Cygwin, or the Git shell (which is installed along with Github for Windows).
Are you ready to start learning?
Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you’ve been dreaming about.
Installation Steps
Installing Node and NPM is pretty straightforward using the installer package available from the Node.js® web site.
Checking if Node & NPM are Installed
Make sure you have Node and NPM installed by running simple commands to see what version of each is installed and to run a simple test program:
Check and Update Your Node and NPM Versions
New versions of Node and NPM come out frequently. To install the updates, just download the installer from the Nodejs.org site and run it again. The new version of Node and NPM will replace the older versions.
How to Uninstall Node and NPM
You uninstall Node.js and NPM the same as you would most Windows software:
With Node.js and NPM installed you’ll soon be able to take advantage of the huge world of NPM modules that can help with a wide variety of tasks both on the web server and on your desktop (or laptop) machine. The NPM site lists all of the official Node packages making it easy to make the choice. Have fun!
Learn with Treehouse
What sets Treehouse apart is their dedication to helping you find your perfect job or develop your own business. – SwitchUp.org
Follow us on Twitter, Instagram, and Facebook for our favorite tips, and to share how your learning is going. We’ll see you there!
If you liked reading this article, you should also look at these two:
GET STARTED NOW
Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you’ve been dreaming about.