我很難與導入lodash模塊。Angular2不能找到Lodash模塊
我去那個解決方案here但它仍然無法正常工作我仍然有錯誤「cannon find module」lodash「」。
我試圖刪除依賴關係,並使用npm install
重新安裝它,它不會改變任何東西。
作品,但import * as _ from "lodash"
不.. 我檢查和lodash是否安裝
這裏是我的package.json
:
{
"name": "newddeskclient",
"version": "0.0.0",
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"@angular/router": "3.0.0",
"@types/node": "^6.0.38",
"angular2-datatable": "^0.6.0",
"angular2-in-memory-web-api": "0.0.20",
"angular2-platform-node": "~2.0.10",
"angular2-universal": "~2.0.10",
"angular2-universal-polyfills": "~2.0.10",
"aspnet-prerendering": "^1.0.6",
"aspnet-webpack": "^1.0.11",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"css": "^2.2.1",
"css-loader": "^0.25.0",
"es6-shim": "^0.35.1",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.1",
"lodash": "^4.17.4",
"preboot": "^4.5.2",
"raw-loader": "^0.5.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"style-loader": "^0.13.0",
"systemjs": "0.19.27",
"to-string-loader": "^1.1.5",
"ts-loader": "^0.8.2",
"typescript": "^2.0.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack-externals-plugin": "^1.0.0",
"webpack-hot-middleware": "^2.10.0",
"webpack-merge": "^0.14.1",
"zone.js": "^0.6.21"
},
"devDependencies": {
"@types/lodash": "^4.14.62",
"typescript": "^2.0.2",
"typings": "^1.3.2",
"gulp": "^3.9.1",
"path": "^0.12.7",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-typescript": "^2.13.6",
"gulp-tsc": "^1.2.0"
}
}
是否有任何解決方案來解決這個問題呢?
[編輯]
這裏是我的tsconfig.json:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"noEmitOnError": true,
"noImplicitAny": false,
"outDir": "../Scripts/AppClient",
"removeComments": false,
"sourceMap": true,
"target": "es5",
"moduleResolution": "node"
},
"exclude": [
"node_modules",
"typings/index",
"typings/index.d.ts"
]
}
你加入tscofig.json文件loadash引用作爲您使用@ tyeps/lodash? – micronyks
Thx回答如此之快!不,我不是這樣的: 「./typings/lodash/lodash.d.ts」,? ' –
''編譯器選項「:{ 」types「:[」node「,」lodash「] } }'。只需在'tsconfig'文件的'tyeps'數組中添加'lodash'條目,並且它應該使用'@ types'系統工作 – micronyks