简体   繁体   English

你如何为 Windows 7 安装 angular-cli

[英]How do you install angular-cli for windows 7

I am trying to install angular-cli for windows.我正在尝试为 Windows 安装 angular-cli。 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.我知道命令是 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

And here you can see an empty folder with no angular-cli folders or anything for that matter:在这里你可以看到一个空文件夹,没有 angular-cli 文件夹或任何与此相关的内容:

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

PLEASE NOTE I am very new to cmd and angular and I really have no idea what steps to take here.请注意,我对 cmd 和 angular 很陌生,我真的不知道在这里要采取什么步骤。

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安装 Node.js Windows Installer 64 位: 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:打开 cmd 窗口(不提升,通常你必须是登录用户)

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

    npm config set https-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 (用你的代理设置替换 Proxy.Company.com:Port)

    Hints: Both settings are required, ask your admins for the correct url.提示:这两个设置都是必需的,请向您的管理员询问正确的 url。 If you need to propagate a user/password use the following syntax:如果您需要传播用户/密码,请使用以下语法:

    npm config set proxy http://user:pass@Proxy.Company.com:Port npm 配置集代理http://user:pass@Proxy.Company.com:Port

  3. Set npm directory for packages (npm 3.10.10 comes with Node.js but we'll update it later):为包设置 npm 目录(npm 3.10.10 随 Node.js 一起提供,但我们稍后会更新):

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

  4. Update npm to the latest version:将 npm 更新到最新版本:

    npm install npm@latest -g npm 安装 npm@latest -g

    Beware: npm update only works with the HTTPS-variant (registry https://registry.npmjs.org/ ).注意:npm update 仅适用于 HTTPS 变体(注册表https://registry.npmjs.org/ )。 With the HTTP-setting (see below) you earn "shasum check failed".使用 HTTP 设置(见下文),您将获得“shasum 检查失败”。

  5. Set npm directory for packages to the non-HTTPS-variant:将包的 npm 目录设置为非 HTTPS 变体:

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

    Reason: the https-variant, which was necessary to update npm itself, does'nt work for all packages, eg @angular/cli@latest or angular-cli or typescript@latest either.原因:更新 npm 本身所必需的 https 变体不适用于所有包,例如 @angular/cli@latest 或 angular-cli 或 typescript@latest。

  6. Install TypeScript:安装打字稿:

    npm install -g typescript@latest 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可能将 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. 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).确保 Visual Studio 获取实际安装的包:工具/选项、左树/项目和解决方案/外部 Web 工具、右侧面板,将 $(PATH) 条目移动到顶部(在 $(DevEnvDir) 条目上方)。 Afterwards close Visual Studio.然后关闭 Visual Studio。

  9. Install AngularJS:安装 AngularJS:

    npm install angular (my version: 1.6.5) npm 安装角度(我的版本:1.6.5)

  10. Install Angular commandline-tool: npm install -g @angular/cli@latest (@angular/cli is the new name for angular-cli)安装 Angular 命令行工具: npm install -g @angular/cli@latest (@angular/cli 是 angular-cli 的新名称)

  11. Check versions (in cmd window; my versions below):检查版本(在 cmd 窗口中;我的版本如下):

    node -v => v6.11.0节点 -v => v6.11.0

    npm -v => 5.1.0 npm -v => 5.1.0

    tsc -v => 2.4.1 tsc -v => 2.4.1

    ng --version => 1.2.0 (@angular/cli) 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)为 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'在 C:\\Users\\<User>\\AppData\\Roaming 中删除目录“npm”
  • In cmd window: npm cache clean or possibly: npm cache clean --force在 cmd 窗口中: npm cache clean 或可能: npm cache clean --force
  • run node-v6.11.0-x64.msi in repair-mode在修复模式下运行 node-v6.11.0-x64.msi
  • continue with Item (2.).继续第 (2.) 项。

Links:链接:

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 .Nodejs 下载页面下载最新版本的Node.js。 I have downloaded Node.js for Windows 64-bit and the filename is: node-v8.9.3-x64.msi我已经下载了适用于 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.在 Windows 资源管理器中,找到下载的 Nodejs .msi 文件。 Double-click the .msi file.双击 .msi 文件。 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.这将在您的机器上安装 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. Angular 命令行界面 (CLI) 是创建新 Angular 项目的最简单方法。 Execute the following NPM command to install Angular CLI:执行以下 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

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.要查看是否安装了 npm,请在命令行中键入以上内容。 Installing @angular/cli安装@angular/cli

npm install @angular/cli

To add this npm package to your local machine, type the above into your command line.要将这个 npm 包添加到您的本地计算机,请在命令行中键入以上内容。 You'll notice a node_modules directory appear in your root where the package is now installed.您会注意到 node_modules 目录出现在您现在安装软件包的根目录中。

If you're having trouble installing packages, check out the helpful docs for installing npm packages locally如果您在安装包时遇到问题,请查看有关在本地安装 npm 包的有用文档

Please note that NG.cmd is installed normally at:请注意NG.cmd正常安装在:

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

...where Administrator could be a user name. ...其中Administrator可以是用户名。

Step 1: Download Node.js第 1 步:下载 Node.js

Download the latest release of Node.js from: Nodejs downloads page.从以下位置下载最新版本的 Node.js:Nodejs 下载页面。 I have downloaded Node.js for Windows 64-bit and the filename is: node-v8.9.3-x64.msi我已经下载了适用于 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.在 Windows 资源管理器中,找到下载的 Nodejs .msi 文件。 Double-click the .msi file.双击 .msi 文件。 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.这将在您的机器上安装 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. Angular 命令行界面 (CLI) 是创建新 Angular 项目的最简单方法。 Execute the following NPM command to install Angular CLI: Step 1: Download Node.js执行以下 NPM 命令以安装 Angular CLI: 步骤 1:下载 Node.js

Download the latest release of Node.js from: Nodejs downloads page.从以下位置下载最新版本的 Node.js:Nodejs 下载页面。 I have downloaded Node.js for Windows 64-bit and the filename is: node-v8.9.3-x64.msi我已经下载了适用于 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.在 Windows 资源管理器中,找到下载的 Nodejs .msi 文件。 Double-click the .msi file.双击 .msi 文件。 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.这将在您的机器上安装 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

使用此命令安装最新版本

npm i @angular/cli @latest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM