Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular typescript错误地安装了lodash_Angular_Typescript_Lodash - Fatal编程技术网

Angular typescript错误地安装了lodash

Angular typescript错误地安装了lodash,angular,typescript,lodash,Angular,Typescript,Lodash,我一直在用..安装lodash typings install dt~lodash --global --save 直到最近我一直工作得很好,但现在我 试图将“lodash”编译为全局模块,但它看起来像一个 外部模块。您需要删除全局选项才能继续 所以我做了 typings install dt~lodash --save 这使安装得以继续 但是现在在我的日志中我得到了错误 typings\modules\lodash\index.d.ts(243,1):错误TS1316:全局模块导出可能仅出

我一直在用..安装lodash

typings install dt~lodash --global --save
直到最近我一直工作得很好,但现在我

试图将“lodash”编译为全局模块,但它看起来像一个 外部模块。您需要删除全局选项才能继续

所以我做了

typings install dt~lodash --save
这使安装得以继续

但是现在在我的日志中我得到了错误

typings\modules\lodash\index.d.ts(243,1):错误TS1316:全局模块导出可能仅出现在顶层

这是一个由打字生成的文件。第243行看起来像

export as namespace _;
Webstorm IDE也给出了完全相同的错误


你知道怎么解决这个问题吗?thx

您也可以安装
lodash
,如下所示:

npm install --save @types/lodash
然后,在.ts文件中:

要么:

import * as _ from "lodash";


要强制下载lodash ts定义文件的早期版本,这两种语法都适用于我:

{
    "globalDependencies": {
        "lodash": "github:DefinitelyTyped/DefinitelyTyped/lodash/index.d.ts#253e456e3c0bf4bd34afaceb7dcbae282da14066",
    }
}
其中,
253e456e3c0bf4bd34afaceb7dcbae282da14066
是github中的提交哈希代码, 或


其中
4.14.0+20161110215204
应为标记版本,但不确定如何生成。我在上次工作下载的.d.ts版本的typings/globals/lodash/typings.json文件中找到了它。

从今天起这里就一样了。我有一个坏主意,删除并重新安装我的所有节点模块和定义文件,我的构建无法再工作了(正常工作了几个星期)。。。看起来某个库在某个地方坏了,但无法确定是哪一个:(你找到什么了吗?无法帮助我恐怕,为了将来的参考,请使用npm shrinkwrap锁定你的npm模块,至于typescript定义,我被卡住了,因为uI认为这与:)好的,我终于明白你的答案了。许多定义文件最近已经更新,没有任何标记或版本,使我的项目崩溃。使用打字,您是否知道是否可以引用特定的提交?类似的东西在“lodash”中不起作用:“registry:dt/lodash#9e1555c7ff12e04e7de962a22b1d914c4eb32a57”这是一个很好的问题kloe
{
    "globalDependencies": {
        "lodash": "github:DefinitelyTyped/DefinitelyTyped/lodash/index.d.ts#253e456e3c0bf4bd34afaceb7dcbae282da14066",
    }
}
{
    "globalDependencies": {
        "lodash": "registry:dt/lodash#4.14.0+20161110215204",
    }
}