VUE3+Typescript 引用process提示错误

 

const debug = process.env.NODE_ENV !== 'production'

提示

TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.

依照提示 先安装

npm i --save-dev @types/node

然后在tsconfig.json的compilerOptions.types节点添加node

{
  "compilerOptions": {
   ..."types": ["vite/client","node"],
    ...
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}

配置完成后,错误提示消失

 

posted @ 2021-12-16 23:49  猪脚踏浪  阅读(6980)  评论(0编辑  收藏  举报