node.js 你如何为 Windows 7 安装 angular-cli

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41798109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:56:46  来源:igfitidea点击:

How do you install angular-cli for windows 7

angularjsnode.jsnpmangular-clinpm-install

提问by tgrim90

I am trying to install angular-cli for windows. I know the command is npm install -g angular-cli, however once I run this command I then try to do ng new however I get an error saying "ng is not a recognized command" I checked the other questions on here saying that you have to add the folder to the PATH variable, however when I check in the folder I've tried to install angular-cli into I don't even see anything.

我正在尝试为 Windows 安装 angular-cli。我知道命令是 npm install -g angular-cli,但是一旦我运行这个命令,我就会尝试做 ng new 但是我得到一个错误说“ng 不是一个可识别的命令”我检查了这里的其他问题说你必须将该文件夹添加到 PATH 变量,但是当我检查文件夹时,我尝试将 angular-cli 安装到我什至看不到任何东西。

Here you can see I've installed the angular-cli using the provided command and that any use of the "ng" command registers and error:

在这里你可以看到我已经使用提供的命令安装了 angular-cli 并且任何“ng”命令的使用都会注册和错误:

x

X

And here you can see an empty folder with no angular-cli folders or anything for that matter:

在这里你可以看到一个空文件夹,没有 angular-cli 文件夹或任何与此相关的内容:

And here you can see an empty folder with no angular-cli folders or anything for that matter

在这里你可以看到一个空文件夹,没有 angular-cli 文件夹或任何与此相关的内容

PLEASE NOTEI am very new to cmd and angular and I really have no idea what steps to take here.

请注意,我对 cmd 和 angular 很陌生,我真的不知道在这里要采取什么步骤。

回答by Erik Nagel

Installation of NodeJs, npm, TypeScript, AngularJS, @angular/cli on Windows 7 Professional SP 1 64-bit:

在 Windows 7 Professional SP 1 64 位上安装 NodeJs、npm、TypeScript、AngularJS、@angular/cli:

Since I have found many valuable hints scattered on various posts only after 'painful' search, here a compact compilation (not my ideas but my experience). Hope it helps.

由于我在“痛苦的”搜索后才发现散布在各种帖子中的许多有价值的提示,这里是一个紧凑的汇编(不是我的想法,而是我的经验)。希望能帮助到你。

  1. install Node.js Windows Installer 64-bit: https://nodejs.org/en/download/node-v6.11.0-x64.msi

  2. If there is a (company-)proxy (installation behind firewall): configure npm against the company-proxy: open cmd window (not elevated, normally you have to be the login-user)

    npm config set proxy http://Proxy.Company.com:Port(replace Proxy.Company.com:Port with your proxy-settings)

    npm config set https-proxy http://Proxy.Company.com:Port(replace Proxy.Company.com:Port with your proxy-settings)

    Hints: Both settings are required, ask your admins for the correct url. If you need to propagate a user/password use the following syntax:

    npm config set proxy http://user:[email protected]:Port

  3. Set npm directory for packages (npm 3.10.10 comes with Node.js but we'll update it later):

    npm config set registry https://registry.npmjs.org/

  4. Update npm to the latest version:

    npm install npm@latest -g

    Beware: npm update only works with the HTTPS-variant (registry https://registry.npmjs.org/). With the HTTP-setting (see below) you earn "shasum check failed".

  5. Set npm directory for packages to the non-HTTPS-variant:

    npm config set registry http://registry.npmjs.org/

    Reason: the https-variant, which was necessary to update npm itself, does'nt work for all packages, e.g. @angular/cli@latest or angular-cli or typescript@latest either.

  6. Install TypeScript:

    npm install -g typescript@latest

  7. Possibly update Visual Studio 2015 to Update 3 (necessary) (everything also works fine with the Community Edition Update 3): Microsoft Visual Studio Professional 2015 Version 14.0.25422.01 Update 3 Microsoft .NET Framework Version 4.6.01055

  8. Ensure, that Visual Studio fetches the actually installed packages: Tools/Options, left-tree/Projects and Solutions/External Web Tools, right panel, move the $(PATH) entry to the top (above the $(DevEnvDir) entries). Afterwards close Visual Studio.

  9. Install AngularJS:

    npm install angular (my version: 1.6.5)

  10. Install Angular commandline-tool: npm install -g @angular/cli@latest (@angular/cli is the new name for angular-cli)

  11. Check versions (in cmd window; my versions below):

    node -v => v6.11.0

    npm -v => 5.1.0

    tsc -v => 2.4.1

    ng --version => 1.2.0 (@angular/cli)

  12. Install optional package installer for Visual Studio (see also section 'Links' below): https://marketplace.visualstudio.com/items?itemName=MadsKristensen.PackageInstaller(...Downloads\Package Installer v2.0.101.vsix)

  1. 安装 Node.js Windows Installer 64 位:https: //nodejs.org/en/download/node-v6.11.0-x64.msi

  2. 如果有(公司)代理(安装在防火墙后面):针对公司代理配置 npm:打开 cmd 窗口(不提升,通常你必须是登录用户)

    npm config set proxy http://Proxy.Company.com:Port(用你的代理设置替换 Proxy.Company.com:Port)

    npm config set https-proxy http://Proxy.Company.com:Port(用你的代理设置替换 Proxy.Company.com:Port)

    提示:这两个设置都是必需的,请向您的管理员询问正确的 url。如果您需要传播用户/密码,请使用以下语法:

    npm 配置集代理http://user:[email protected]:Port

  3. 为包设置 npm 目录(npm 3.10.10 随 Node.js 一起提供,但我们稍后会更新):

    npm 配置设置注册表https://registry.npmjs.org/

  4. 将 npm 更新到最新版本:

    npm 安装 npm@latest -g

    注意:npm update 仅适用于 HTTPS 变体(注册表https://registry.npmjs.org/)。使用 HTTP 设置(见下文),您将获得“shasum 检查失败”。

  5. 将包的 npm 目录设置为非 HTTPS 变体:

    npm 配置设置注册表http://registry.npmjs.org/

    原因:更新 npm 本身所必需的 https 变体不适用于所有包,例如 @angular/cli@latest 或 angular-cli 或 typescript@latest。

  6. 安装打字稿:

    npm install -g typescript@latest

  7. 可能将 Visual Studio 2015 更新为 Update 3(必要)(使用 Community Edition Update 3 一切正常):Microsoft Visual Studio Professional 2015 Version 14.0.25422.01 Update 3 Microsoft .NET Framework Version 4.6.01055

  8. 确保 Visual Studio 获取实际安装的包:工具/选项、左树/项目和解决方案/外部 Web 工具、右侧面板,将 $(PATH) 条目移动到顶部(在 $(DevEnvDir) 条目上方)。然后关闭 Visual Studio。

  9. 安装 AngularJS:

    npm 安装角度(我的版本:1.6.5)

  10. 安装 Angular 命令行工具: npm install -g @angular/cli@latest (@angular/cli 是 angular-cli 的新名称)

  11. 检查版本(在 cmd 窗口中;我的版本如下):

    节点 -v => v6.11.0

    npm -v => 5.1.0

    tsc -v => 2.4.1

    ng --version => 1.2.0 (@angular/cli)

  12. 为 Visual Studio 安装可选包安装​​程序(另请参阅下面的“链接”部分):https: //marketplace.visualstudio.com/items?itemName=MadsKristensen.PackageInstaller (...Downloads\Package Installer v2.0.101.vsix)

If something had gone wrong, restart with the following steps:

如果出现问题,请按照以下步骤重新启动:

  • In C:\Users\<User>\AppData\Roaming delete the directory 'npm'
  • In cmd window: npm cache clean or possibly: npm cache clean --force
  • run node-v6.11.0-x64.msi in repair-mode
  • continue with Item (2.).
  • 在 C:\Users\<User>\AppData\Roaming 中删除目录“npm”
  • 在 cmd 窗口中: npm cache clean 或可能: npm cache clean --force
  • 在修复模式下运行 node-v6.11.0-x64.msi
  • 继续第 (2.) 项。

Links:

链接:

回答by Aj Tech Developer

Latest versions of Node.js and Angular CLI can be setup on Windows 7 in few simple steps:

只需几个简单的步骤,即可在 Windows 7 上设置最新版本的 Node.js 和 Angular CLI:

Step 1: Download Node.js

第 1 步:下载 Node.js

Download the latest release of Node.js from: Nodejs downloads page. I have downloaded Node.js for Windows 64-bit and the filename is: node-v8.9.3-x64.msi

Node.js的下载从最新版本:的NodeJS下载页面。我已经下载了适用于 Windows 64 位的 Node.js,文件名是:node-v8.9.3-x64.msi

Step 2: Install Node.js for Windows.

第 2 步:为 Windows 安装 Node.js。

In Windows Explorer, locate the downloaded Nodejs .msi file. Double-click the .msi file. A set of screens will appear to guide you through the installation process. This will install Node.js and Node Package Manager (NPM) on your machine.

在 Windows 资源管理器中,找到下载的 Nodejs .msi 文件。双击 .msi 文件。将出现一组屏幕,指导您完成安装过程。这将在您的机器上安装 Node.js 和 Node Package Manager (NPM)。

Step 3: Verify Node.js Installation

第 3 步:验证 Node.js 安装

Type the following commands to check the versions of Node.js and NPM

输入以下命令检查 Node.js 和 NPM 的版本

node -v
npm -v

Step 4: Install Angular CLI

第 4 步:安装 Angular CLI

Angular Command Line Interface (CLI) is the easiest way to create new Angular projects. Execute the following NPM command to install Angular CLI:

Angular 命令行界面 (CLI) 是创建新 Angular 项目的最简单方法。执行以下 NPM 命令来安装 Angular CLI:

npm install @angular/cli -g

After this installation, the CLI tool can be accessed by using ng commands.

安装完成后,可以使用 ng 命令访问 CLI 工具。

Step 5: Verify Angular CLI

第 5 步:验证 Angular CLI

Type the command:

输入命令:

ng -v

I have also put all these steps in my blog: Setup Node.js and Angular CLI

我还将所有这些步骤放在我的博客中:Setup Node.js and Angular CLI

回答by Shaaban Ebrahim

Test It!

测试一下!

node -v

To see if Node is installed, type the above on your command line.

要查看是否安装了 Node,请在命令行中键入以上内容。

npm -v

To see if npm is installed, type the above on your command line. Installing @angular/cli

要查看是否安装了 npm,请在命令行中键入以上内容。安装@angular/cli

npm install @angular/cli

To add this npm package to your local machine, type the above into your command line. You'll notice a node_modules directory appear in your root where the package is now installed.

要将这个 npm 包添加到您的本地计算机,请在命令行中键入以上内容。您会注意到 node_modules 目录出现在您现在安装软件包的根目录中。

If you're having trouble installing packages, check out the helpful docs for installing npm packages locally

如果您在安装包时遇到问题,请查看有关在本地安装 npm 包的有用文档

回答by Young

Please note that NG.cmdis installed normally at:

请注意,NG.cmd它通常安装在:

C:\Users\Administrator\AppData\Roaming\npm\ng.cmd

...where Administratorcould be a user name.

...哪里Administrator可以是用户名。

回答by Bhavsar1311

Step 1: Download Node.js

第 1 步:下载 Node.js

Download the latest release of Node.js from: Nodejs downloads page. I have downloaded Node.js for Windows 64-bit and the filename is: node-v8.9.3-x64.msi

从以下位置下载最新版本的 Node.js:Nodejs 下载页面。我已经下载了适用于 Windows 64 位的 Node.js,文件名是:node-v8.9.3-x64.msi

Step 2: Install Node.js for Windows.

第 2 步:为 Windows 安装 Node.js。

In Windows Explorer, locate the downloaded Nodejs .msi file. Double-click the .msi file. A set of screens will appear to guide you through the installation process. This will install Node.js and Node Package Manager (NPM) on your machine.

在 Windows 资源管理器中,找到下载的 Nodejs .msi 文件。双击 .msi 文件。将出现一组屏幕,指导您完成安装过程。这将在您的机器上安装 Node.js 和 Node Package Manager (NPM)。

Step 3: Verify Node.js Installation

第 3 步:验证 Node.js 安装

Type the following commands to check the versions of Node.js and NPM

输入以下命令检查 Node.js 和 NPM 的版本

node -v npm -v

节点 -v npm -v

Step 4: Install Angular CLI

第 4 步:安装 Angular CLI

Angular Command Line Interface (CLI) is the easiest way to create new Angular projects. Execute the following NPM command to install Angular CLI: Step 1: Download Node.js

Angular 命令行界面 (CLI) 是创建新 Angular 项目的最简单方法。执行以下 NPM 命令以安装 Angular CLI: 步骤 1:下载 Node.js

Download the latest release of Node.js from: Nodejs downloads page. I have downloaded Node.js for Windows 64-bit and the filename is: node-v8.9.3-x64.msi

从以下位置下载最新版本的 Node.js:Nodejs 下载页面。我已经下载了适用于 Windows 64 位的 Node.js,文件名是:node-v8.9.3-x64.msi

Step 2: Install Node.js for Windows.

第 2 步:为 Windows 安装 Node.js。

In Windows Explorer, locate the downloaded Nodejs .msi file. Double-click the .msi file. A set of screens will appear to guide you through the installation process. This will install Node.js and Node Package Manager (NPM) on your machine.

在 Windows 资源管理器中,找到下载的 Nodejs .msi 文件。双击 .msi 文件。将出现一组屏幕,指导您完成安装过程。这将在您的机器上安装 Node.js 和 Node Package Manager (NPM)。

Step 3: Verify Node.js Installation

第 3 步:验证 Node.js 安装

Type the following commands to check the versions of Node.js and NPM

输入以下命令检查 Node.js 和 NPM 的版本

node -v npm -v

节点 -v npm -v

Step 4: Install Angular CLI This command will install latest version of angular command line.

第 4 步:安装 Angular CLI 此命令将安装最新版本的 angular 命令行。

npm i -g @angular/cli

npm i -g @angular/cli

回答by Abdus Salam Azad

Use this command to install latest version

使用此命令安装最新版本

npm i @angular/cli @latest