typings always complaining about global module

左心房为你撑大大i 提交于 2019-12-05 13:51:33

问题


I am very new to typescript. Whatever typings I try to install, I get:

typings ERR! message Attempted to compile "angular" as an external module, but it looks like a global module.

I am just trying to do

typings install dt~angular

What am I doing wrong?

Update: If you are coming here with little knowledge (as I was when writing this question) - consider using npm/@types. More info and discussion.


回答1:


As error message suggests, you should use --global option:

typings install dt~angular --global --save

See detailed step-by-step tutorial for setting up Node.js project with TypeScript support in IntelliJ IDEA / Webstorm or Visual Studio Code

TypeScript and tools around it are evolving very fast. What worked yesterday don't work any more.




回答2:


What am I doing wrong?

Global modules need to be compiled with --ambient

typings install angular --ambient --save

You can see more on the need to use ambient here : When to use ambient while searching for a type definition?



来源:https://stackoverflow.com/questions/37357619/typings-always-complaining-about-global-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!