Ambient flag is deprecated

2019-06-24 02:22发布

问题:

I am trying to install dependency in my app i get err that ambient flag is depreciated and also terminal says to replace it with --global i done it but now terminal says that "Unable to find "node" ("npm") in the registry". I followed this link to make e2e testing http://lathonez.github.io/2016/ionic-2-e2e-testing/

yokeshs-Mac-mini:easycloud yokesh$ sudo typings install express --save --ambient
typings ERR! deprecated The "ambient" flag is deprecated. Please use "global" instead
yokeshs-Mac-mini:easycloud yokesh$ sudo typings install --global --save angular-protractor jasmine node selenium-webdriver
typings ERR! message Unable to find "node" ("npm") in the registry. Did you want to try searching another source? Also, if you want contribute these typings, please help us: 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! cwd /Users/yokesh/easycloud
typings ERR! system Darwin 15.5.0
typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install" "--global" "--save" "angular-protractor" "jasmine" "node" "selenium-webdriver"
typings ERR! node -v v4.4.3
typings ERR! typings -v 1.1.0

typings ERR! If you need help, you may report this error at:
typings ERR!   <https://github.com/typings/typings/issues>
yokeshs-Mac-mini:easycloud yokesh$ 

I just wanted to know how to install this command "typings install --ambient --save angular-protractor jasmine node selenium-webdriver"

回答1:

As of version 1.0 TypeScript Definition Manager made some updates (see here) 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

Referencing the Quick Start example on the GitHub page, what you need to do is explicitly reference the registry where you are installing the type definition(s) from so that Typings will know where to look for it.

Example (Windows CLI)

Find the package by searching for it

typings search *name*

Then get the source from the printed result table in the command line (source column)

| NAME | SOURCE | HOMEPAGE | DESCRIPTION | VERSIONS | UPDATED |
|--------------------------------------------------------------
|      |        |          |             |          |         |
|      |        |          |             |          |         |

In this example each package you want installing returns with the source dt. In my install command I now have to tell typings explicitly to install each package from dt (DefinitelyTyped).

typings install --global --save dt~angular-protractor dt~jasmine dt~node dt~selenium-webdriver