最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to install Angular2 universal when the docs on the site are outdated? - Stack Overflow

programmeradmin4浏览0评论

The maintainers at angular2-universal have not updated their site:

Problem 1)

typings install node express body-parser serve-static express-serve-static-core mime --ambient
typings ERR! deprecated The "ambient" flag is deprecated. Please use "global" instead

Problem 2)

    typings install node express body-parser serve-static express-serve-static-core mime --global
typings INFO globaldependencies "express" 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: 
typings ERR! caused by  responded with 404, expected it to equal 200

typings ERR! cwd /Users/davidmontgomery/Documents/frontend/green
typings ERR! system Darwin 15.6.0
typings ERR! mand "/usr/local/bin/node" "/usr/local/bin/typings" "install" "node" "express" "body-parser" "serve-static" "express-serve-static-core" "mime" "--global"
typings ERR! node -v v4.5.0
typings ERR! typings -v 1.3.3

typings ERR! If you need help, you may report this error at:
typings ERR!   <;

How do I resolve? I am using a mac.

The maintainers at angular2-universal have not updated their site:

Problem 1)

typings install node express body-parser serve-static express-serve-static-core mime --ambient
typings ERR! deprecated The "ambient" flag is deprecated. Please use "global" instead

Problem 2)

    typings install node express body-parser serve-static express-serve-static-core mime --global
typings INFO globaldependencies "express" 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./typings/registry
typings ERR! caused by https://api.typings/entries/npm/node/versions/latest responded with 404, expected it to equal 200

typings ERR! cwd /Users/davidmontgomery/Documents/frontend/green
typings ERR! system Darwin 15.6.0
typings ERR! mand "/usr/local/bin/node" "/usr/local/bin/typings" "install" "node" "express" "body-parser" "serve-static" "express-serve-static-core" "mime" "--global"
typings ERR! node -v v4.5.0
typings ERR! typings -v 1.3.3

typings ERR! If you need help, you may report this error at:
typings ERR!   <https://github./typings/typings/issues>

How do I resolve? I am using a mac.

Share Improve this question edited Sep 11, 2017 at 1:43 glemiere 5,0247 gold badges40 silver badges61 bronze badges asked Sep 7, 2016 at 9:49 TampaTampa 78.3k123 gold badges289 silver badges428 bronze badges 1
  • Hey! Don't forget to select the right answer for your question ;-) – glemiere Commented Sep 24, 2017 at 23:09
Add a ment  | 

3 Answers 3

Reset to default 18

The solution is to install node separately with the --global flag, because it's the only one that needs to be installed globally.

typings install dt~node --global
typings install dt~express dt~body-parser dt~serve-static dt~express-serve-static-core dt~mime

EDIT : You don't need angular universal for server side rendering anymore, as it is now part of angular core.

As of version 1.0 TypeScript Definition Manager made some updates ([see here][1]) which included deprecating the --ambient flag.

  • Usages of ambient are now global
    • That means in typings.json any ambientDependencies should be renamed globalDependencies and any ambientDevDependencies should be renamed globalDevDependencies.
    • It also means --ambient is now --global ...

=> For more information, check this out. [typings github]: https://github./typings/typings [original answer]: Ambient flag is deprecated

Thus, you should use this pattern ↓

typings install dt~PackageName --save --global

ex) typings install dt~body-parser --global --save

Comment below, if you need more help.

With a couple of things changing across typescript and the universal team working overtime to updating universal to the latest releases of angular rc5 and rc6, things have fallen a bit behind on the documentation front. If you want to get started quickly, checkout out the universal starter kit at https://github./angular/universal-starter that should work for you.

发布评论

评论列表(0)

  1. 暂无评论