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

查看:157
本文介绍了如何为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位上安装NodeJ,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配置设置代理 http://Proxy.Company.com:Port (替换Proxy.Company) .com:带有您的代理设置的端口)

    npm配置设置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安装npm @ latest -g

    当心:npm更新仅适用于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(必要) (一切都与Community Edition Update 3兼容): Microsoft Visual Studio专业版2015 版本14.0.25422.01更新3 Microsoft .NET Framework版本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 (... Downloads \ Package Installer v2.0.101.vsix)

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

  • 在C:\ Users \< User> \ AppData \ Roaming中,删除目录'npm'
  • 在cmd窗口中:npm缓存清理 或者可能是: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天全站免登陆