你如何为 Windows 7 安装 angular-cli [英] How do you install angular-cli for windows 7

查看:32
本文介绍了你如何为 Windows 7 安装 angular-cli的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

解决方案

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

因为我发现很多有价值的提示散落在各个帖子上经过痛苦"的搜索,这里有一个紧凑的汇编(不是我的想法,而是我的经验).希望有帮助.

  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(替换代理.Company.com:使用您的代理设置端口)

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

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

  3. 设置包的 npm 目录(npm 3.10.10 带有 Node.js,但我们稍后会更新):

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

  4. 更新 npm 到最新版本:

    npm install npm@latest -g

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

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

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

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

  6. 安装 TypeScript:

    npm install -g typescript@latest

  7. 可能将 Visual Studio 2015 更新到 Update 3(必要)(在社区版更新 3 中一切正常):微软 Visual Studio 专业版 2015版本 14.0.25422.01 更新 3Microsoft .NET 框架版本 4.6.01055

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

  9. 安装 AngularJS:

    npm install angular(我的版本:1.6.5)

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

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

    node -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(...下载\软件包安装程序 v2.0.101.vsix)

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

  • 在 C:\Users\\AppData\Roaming 中删除目录npm"
  • 在 cmd 窗口中: npm cache clean或者可能: npm cache clean --force
  • 在修复模式下运行 node-v6.11.0-x64.msi
  • 继续第 (2.) 项.

链接:

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.

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:

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

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

解决方案

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

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: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 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)

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.).

Links:

这篇关于你如何为 Windows 7 安装 angular-cli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆