SystemJS loader无法在libs/@ types/lodash中找到@ types/lodash

问题描述:

我一直在努力获取lodash的工作,并遇到了this。我遵循这里提供的指导方针,但仍然不断收到下面的错误。SystemJS loader无法在libs/@ types/lodash中找到@ types/lodash

Error: (SystemJS) XHR error (404) loading https://localhost:44382/libs/@types/lodash(…)(anonymous function) @ (index):34ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339 

这是我的tsconfig文件

{ 
"compileOnSave": true, 
"compilerOptions": { 
"typeRoots": [ 
    "libs/@types/" 
], 
"types": ["lodash"], 
"emitDecoratorMetadata": true, 
"experimentalDecorators": true, 
"watch": true, 
"module": "commonjs", 
"noEmitOnError": true, 
"noImplicitAny": false, 
"outDir": "../wwwroot/appScripts/", 
"removeComments": false, 
"sourceMap": true, 
"target": "es6", 
"moduleResolution": "node" 
}, 
"exclude": [ 
"node_modules", 
"typings/index", 
"typings/index.d.ts", 
"typings/browser", 
"typings/browser.d.ts" 
] 
} 

enter image description here

原来我是用不符合lodash兼容打字稿的版本。 我从打字稿2.0.8切换回2.0.3,一切都恰到好处。我使用的lodash版本是4.16.6,@ types/lodash版本是4.14.38