typescript - Ionic 2 angular-moment-timezone - 無法重新宣告區塊作用域的變數 'tz'
我不太確定我做了什麼,但今天我在我的 Ionic 專案中安裝了 angular-moment-timezone,並成功運行,也能順利執行 ionic serve,但是後來我決定刪除我的 node_modules 資料夾。刪除後,我執行了 npm i,全部完成後,每次我嘗試運行 ionic serve 時,都會出現這些錯誤:
Typescript Error
Cannot redeclare block-scoped variable 'tz'.
node_modules/@types/moment-timezone/index.d.ts
undefined
undefined
Typescript Error
Cannot redeclare block-scoped variable 'tz'.
node_modules/angular-moment-timezone/node_modules/@types/moment-timezone/index.d.ts
undefined
undefined
我完全不知道我做錯了什麼,到目前為止我也沒找到任何可以幫助的東西。有人遇到過同樣的問題嗎?
答案#1
我們的依賴中有 @types/moment-timezone,這導致了錯誤。
無法重新宣告區塊作用域變數 'tz' moment-timezone
自 moment-timezone 版本 0.5.30 起,d.ts 文件將包含在 moment-timezone 中。你可以刪除它
npm uninstall @types/moment-timezone