簡體   English   中英

每次我嘗試部署函數時,我都會收到“找不到類型定義文件...”

[英]Everytime I try to deploy functions I get "Cannot find type definition file for ..."

我厭倦了看到這些錯誤,它們阻止我部署我的代碼,它們是什么意思?

目前我有這個錯誤:

error TS2688: Cannot find type definition file for 'linkifyjs 2'.

error TS2688: Cannot find type definition file for 'node 2'.

我什至沒有在我的代碼中使用linkifyjs 2 ,那么出於什么原因我必須處理與之相關的錯誤呢?

這是我的 tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": ["src"]
}

有人可以解釋這些錯誤的起源以及如何避免它們嗎?

我也面臨這個問題。 通過這種方式,我解決了這個問題。

您需要做的第一件事是確保您安裝了 Node.js 的類型。 在項目的根目錄中打開終端並運行以下命令。

npm i -D @types/node

如果錯誤仍未解決,請嘗試重新啟動 IDE。

如果這沒有幫助,請確保 tsconfig.json 文件中的類型數組包含“節點”。

{
  "compilerOptions": {
    "types": [
      // ... your other types
      "node"
    ],
  },
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM