我已经使用typings install dt~moment --save --global
全局安装了moment typing
运行typings list
给我:
├── lodash@4.0.0
├── es6-shim (global)
└── moment (global)
我已经决定卸载它使用typings uninstall moment --global
运行typings list
给我:
├── lodash@4.0.0
└── es6-shim (global)
现在我去安装在当前目录使用typings install dt~moment --save
,得到以下错误:
typings ERR! message Attempted to compile "moment" as an external module, but it looks like a global module. You'll need to enable the global option to continue.
为什么会发生这种情况,我之前也尝试过清除缓存,但没有帮助。
node v5
npm v3.3.9
tsc v1.8.10
编辑:如果你升级到typescript 2.0,你可以使用npm安装类型。
npm install @types/moment
https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/@types/moment
也许有帮助。