安装Angular 2 Universal

更新:

我正在尝试使用本指南来安装Angular 2 Universal,但是当我运行以下命令时,出现一些错误。

这里是命令:

typings install node express body-parser serve-static dexpress-serve-static-core mime --global --save 

而错误是:

 C:\Users\user\Desktop\myApp>typings install node express body-parser serve-static dexpress-serve-static-core mime --global --save typings INFO globaldependencies "express" lists global dependencies on "node" that must be installed manually typings INFO globaldependencies "serve-static" lists global dependencies on "node" that must be installed manually typings INFO globaldependencies "body-parser" lists global dependencies on "node" that must be installed manually typings ERR! message Unable to find "node" ("npm") in the registry. typings ERR! message However, we found "node" for 2 other sources: "dt" and "env" typings ERR! message You can install these using the "source" option. typings ERR! message We could use your help adding these typings to the registry: https://github.com/typings/registry typings ERR! caused by https://api.typings.org/entries/npm/node/versions/latest responded with 404, expected it to equal 200 typings ERR! typings ERR! cwd C:\Users\user\Desktop\myApp typings ERR! system Windows_NT 10.0.14393 typings ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\typings\\dist\\bin.js" "install" "node" "express" "body-parser" "serve-static" "dexpress-serve-static-core" "mime" "--global" "--save" typings ERR! node -v v6.9.2 typings ERR! typings -v 2.0.0 typings ERR! typings ERR! If you need help, you may report this error at: typings ERR! <https://github.com/typings/typings/issues> 

我正在使用节点版本v6.9.2和npm 4.0.5

更新nodeJS,只需在主页上下载LTS版本,安装它,然后更新npm:

 npm install npm@latest -g 

再次尝试你的第一个命令,它会起作用。

我已经通过以下方式安装了Angular Universal:

  1. 下载初学者项目: https : //github.com/angular/universal-starter
  2. 使用terminal或IDE将NPM安装到项目文件夹中。 对于Mac,该命令是:

    sudo npm安装

否则使用“sudo”很重要,否则访问时可能会出现一些错误。

  1. npm开始

  2. localhost:3000