Windows10 node-red environment configuration from scratch (node.js, npm environment configuration)

1 Introduction

To install node-red under Windows, you first need to open the power shell, then configure node.js and npm (in fact, these two are one step), then install node-red with npm, and finally run perfectly. But, there are always stumblings on the beautiful road. I installed node-red to sum up my experience today, and it has taken two days. I will tell you about the problems and solutions I encountered during the installation. Maybe you will encounter the same Here comes this problem.

2 open power shell

2.1 Introduction to power shell

Portal

2.2 Search for power shell in the search box and open

search bar
Search power shell

3 install node.js and npm

3.1 Reasons for installing node.js and npm

Because most (almost all) of the tutorials on installing node-red provided on the Internet are installed with npm in the power shell environment, we need to configure an npm environment to install node-red.

3.2 Why is node.js and node-red so similar

Portal

3.3 Installing node.js will automatically install npm

3.3.1 Installation

reference

3.3.1.1. Download nodejs (official website address: http://nodejs.org)
Download node.js
3.3.1.2. Install node.js basically directly "NEXT".
3.3.1.3. Test
run in power shell

node -v
npm  -v

The test result returns the version number
3.3.1.4. Installation is complete

3.3.2 Uninstall node.js

reference

3.4 The first problem is that node.js installation is complete and it does not run successfully

Solution (find it by yourself): You only need to restart the computer . This may involve some registry reloading issues. My solution is straightforward and rude—restart the computer.

4 install node-red

4.1 Run commands in power shell

npm install -g --unsafe-perm node-red 

Normally, the installation can be completed directly, but so far I have begun to encounter many problems that others have not encountered before

4.2 The second problem is particularly slow during installation

reference

4.2.1 Use npm install --verbose to view progress

Refer to
npm install often getting stuck, and there is often no information in the command line, so we don't know the reason.
We can use the command npm install --verbose instead. You can view and display the current progress to which step, very detailed information. Convenient for us to troubleshoot.
When we check, we will find that the access URL is very long. At this time, we can basically determine that the installation cannot be completed due to network reasons. At this time, we need to change to a domestic mirror source.

4.3.2 Change source

4.3.2.1. Install Taobao mirror

npm config set registry " https://registry.npm.taobao.org "       

4.3.2.2. Taobao mirror can be uninstalled when not needed

  npm config set disturl https://npm.taobao.org/dist

4.3.3 Clear the cache and reinstall

4.3.3.1. Clear cache

npm cache clean --force

4.3.3.2. Reinstall

npm install -g --unsafe-perm node-red 

4.3.3.3. Successful installation

4.4 The third problem will report an error during installation

reference

4.4.1 Error report form

Reference The
Report an error
cause of the error I boldly guess there are two
4.4.1.1. Network problems
4.4.1.2. Repeat installation without installation

4.4.2 Solution 1 : Refer to the first problem and reinstall after changing the source

4.4.3 Solution 2 : Clear the cache first, and then reinstall

4.4.3.1. Clear cache

npm cache clean --force

4.4.3.2. Reinstall

npm install -g --unsafe-perm node-red 

4.4.3.3. Successful installation

5 run node-red

5.1 Run in power shell

node-red

5.2 Successful operation, installation is complete

Generally, it can be directly run successfully.
If the operation is not successful, refer to the first problem solution.
If the operation is not successful after restarting, and the following prompt is thrown, then you are as lucky as me and encountered the fourth problem.

5.3 The fourth problem power shell prohibits script execution

reference

5.3.1 Form

& : 无法加载文件 C:\Users\liuzidong\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateyInstall.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。所在位置 行:242 字符: 3+ & $chocInstallPS1+   ~~~~~~~~~~~~~~~    + CategoryInfo          : SecurityError: (:) [],PSSecurityException    + FullyQualifiedErrorId : UnauthorizedAccess
PowerShell因为在此系统中禁止执行脚本的解决方法

5.3.2 Reason

You must be using power shell for the first time like me ^ _ ^
because when you start Windows PowerShell on your computer for the first time, the current execution policy is probably Restricted (the default setting).
The Restricted policy does not allow any scripts to run.
To learn about the current execution policy on the computer, type:

get-executionpolicy

5.3.3 Solution

set-ExecutionPolicy RemoteSigned

To run unsigned scripts written by you and signed scripts from other users on the local computer, use the following command to change the execution policy on the computer to RemoteSigned:
set-executionpolicy remotesigned
For more information, see Set-ExecutionPolicy.
Execute "set-ExecutionPolicy RemoteSigned": The
execution policy changes the execution policy to prevent you from executing untrusted scripts. Changing the execution policy may expose you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution strategy? [Y] Yes (Y) [N] No (N) [S] Suspend (S) [?] Help (default is "Y"): y

6 You're done (if you encounter new problems, you can leave a message in the comment area and I will solve them and add them to this blog post)

Guess you like

Origin blog.csdn.net/yong15565566939/article/details/105033931