vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.85k stars 398 forks source link

执行vue-tsc --noEmit --skipLibCheck内存溢出 #3817

Closed huangshan-web closed 3 months ago

huangshan-web commented 10 months ago

//package.json { "name": "test", "version": "0.0.0", "description": "", "author": { "name": "xxx" }, "scripts": { "dev": "vite", "type-check": "vue-tsc --noEmit --skipLibCheck", "build:stage": "vite build --mode staging --force", "build:prod": "vue-tsc --noEmit && NODE_OPTIONS=--max_old_space_size=10240 vite build", "preview:stage": "pnpm build:stage && vite preview --port 3333", "preview:prod": "pnpm build:prod && vite preview", "lint:eslint": "eslint --cache --max-warnings 0 \"src//*.{vue,js,ts,tsx}\" --fix", "lint:prettier": "prettier --write \"src/*/.{js,ts,json,tsx,css,less,scss,vue,html,md}\"", "lint": "pnpm lint:eslint && pnpm lint:prettier", "prepare": "husky install" }, "dependencies": { "@antv/layout": "^0.3.23", "@antv/x6": "^2.4.0", "@antv/x6-plugin-clipboard": "^2.1.4", "@antv/x6-plugin-dnd": "^2.0.4", "@antv/x6-plugin-export": "^2.1.5", "@antv/x6-plugin-history": "^2.2.0", "@antv/x6-plugin-keyboard": "^2.2.0", "@antv/x6-plugin-minimap": "^2.0.5", "@antv/x6-plugin-scroller": "^2.0.8", "@antv/x6-plugin-selection": "^2.1.5", "@antv/x6-plugin-snapline": "^2.1.6", "@antv/x6-plugin-stencil": "^2.0.2", "@antv/x6-plugin-transform": "^2.1.5", "@antv/x6-vue-shape": "^2.0.9", "@element-plus/icons-vue": "^2.0.10", "@icon-park/vue-next": "^1.4.2", "@idux/cdk": "^1.4.2", "@idux/components": "^1.4.2", "@types/codemirror": "^5.60.10", "@vueuse/core": "^10.2.1", "@wangeditor/editor": "^5.1.23", "axios": "^1.2.2", "bpmn-js": "^8.10.0", "bpmn-js-task-resize": "^1.2.0", "bpmn-js-token-simulation": "^0.10.0", "codemirror": "~5.65.12", "codemirror-editor-vue3": "^2.0.6", "core-js": "^3.6.5", "dayjs": "^1.11.7", "diagram-js-minimap": "^2.1.1", "echarts": "^5.4.2", "element-plus": "^2.3.7", "html2canvas": "^1.4.1", "insert-css": "2.0.0", "js-cookie": "^3.0.1", "lodash-es": "^4.17.21", "min-dash": "^3.5.2", "mitt": "^3.0.0", "monaco-editor": "^0.39.0", "normalize.css": "^8.0.1", "nprogress": "^0.2.0", "path-browserify": "^1.0.1", "path-to-regexp": "^6.2.1", "pinia": "^2.0.28", "pinia-plugin-persist": "^1.0.0", "runscript": "^1.5.3", "screenfull": "^6.0.2", "sm-crypto": "^0.3.12", "sortablejs": "^1.15.0", "sql-formatter": "^15.0.2", "view-ui-plus": "^1.3.1", "vue": "^3.2.45", "vue-router": "^4.1.6", "vuedraggable": "^4.1.0", "vxe-table": "^4.3.8", "vxe-table-plugin-element": "^3.0.6", "wangeditor5-for-vue3": "^1.0.0", "xe-utils": "^3.5.13" }, "devDependencies": { "@types/js-cookie": "^3.0.2", "@types/lodash-es": "^4.17.6", "@types/node": "^18.11.18", "@types/nprogress": "^0.2.0", "@types/path-browserify": "^1.0.0", "@types/sortablejs": "^1.15.2", "@typescript-eslint/eslint-plugin": "^5.48.0", "@typescript-eslint/parser": "^5.48.0", "@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue-jsx": "^3.0.0", "@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-typescript": "^11.0.2", "eslint": "^8.31.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.8.0", "glob": "^10.3.10", "husky": "^8.0.3", "lint-staged": "^13.1.0", "prettier": "^2.8.2", "rollup-plugin-visualizer": "^5.9.2", "sass": "^1.57.1", "terser": "^5.16.1", "typescript": "^4.9.4", "unplugin-auto-import": "^0.15.3", "unplugin-vue-define-options": "^1.2.3", "vite": "^4.0.4", "vite-plugin-compression": "^0.5.1", "vite-plugin-monaco-editor": "^1.1.0", "vite-plugin-optimize-persist": "^0.1.2", "vite-plugin-package-config": "^0.1.1", "vite-plugin-svg-icons": "^2.0.1", "vite-svg-loader": "^4.0.0", "vue-eslint-parser": "^9.1.0", "vue-tsc": "^1.0.24" }, "lint-staged": { ".{js,jsx,vue,ts,tsx}": [ "eslint --fix", "prettier --write" ], ".{scss,less,css,html,md}": [ "prettier --write" ], "package.json": [ "prettier --write" ], "{!(package).json,.!(browserslist)rc}": [ "prettier --write--parser json" ] }, "keywords": [ "vue", "vue3", "vite", "element-plus", "ts", "typescript" ], "license": "MIT" } // tsconfig.json { "compilerOptions": { "target": "esnext", / https://cn.vitejs.dev/guide/features.html#typescript-compiler-options */ "useDefineForClassFields": true, "module": "esnext", "moduleResolution": "node", / TS 严格模式 */ // "strict": true, "jsx": "preserve", "importHelpers": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "allowJs": true, "outDir": "./dist", "sourceMap": true, "resolveJsonModule": true, /* https://cn.vitejs.dev/guide/features.html#typescript-compiler-options / "isolatedModules": true, "esModuleInterop": true, "lib": ["dom", "dom.iterable", "esnext"], // lib 这个属性来设置需要引入的全局类型声明 "skipLibCheck": true, "types": [ "node", "vite/client", / Element Plus 的 Volar 插件支持 */ "element-plus/global", "unplugin-vue-define-options/macros-global", "wangeditor5-for-vue3/global" ], / baseUrl 用来告诉编译器到哪里去查找模块,使用非相对模块时必须配置此项 */ "baseUrl": ".", /* 非相对模块导入的路径映射配置,根据 baseUrl 配置进行路径计算 / "paths": { "@/": ["src/"] } }, / 编译器默认编译文件 */ "include": ["src//*.js", "src/*/.ts", "src//*.d.ts", "src//*.tsx", "src/*/.vue", "types//*.d.ts", "vite.config.ts"], /* 编译器默认排除的编译文件 / "exclude": ["node_modules", "dist"] } 加大内存后还是报内存异常 vue-tsc升级到最新版本也不行

so1ve commented 10 months ago

Please provide a minimal reproduction.

huangshan-web commented 10 months ago

Please provide a minimal reproduction.

PS D:\sdlake-web> pnpm type-check

sdlake@0.0.0 type-check D:\sdlake-web vue-tsc --noEmit --skipLibCheck

<--- Last few GCs --->

[5164:000002BDCE4C8C60] 89310 ms: Scavenge (reduce) 2038.8 (2082.5) -> 2038.0 (2082.8) MB, 4.8 / 0.0 ms (average mu = 0.181, current mu = 0.054) allocation failure [5164:000002BDCE4C8C60] 89320 ms: Scavenge (reduce) 2038.8 (2082.8) -> 2038.1 (2082.8) MB, 4.0 / 0.0 ms (average mu = 0.181, current mu = 0.054) allocation failure [5164:000002BDCE4C8C60] 89332 ms: Scavenge (reduce) 2038.9 (2082.8) -> 2038.1 (2083.0) MB, 7.1 / 0.0 ms (average mu = 0.181, current mu = 0.054) allocation failure

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF78A2730AF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+112511 2: 00007FF78A202216 DSA_meth_get_flags+65542 3: 00007FF78A2030CD node::OnFatalError+301 4: 00007FF78AB34B6E v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF78AB1F09D v8::SharedArrayBuffer::Externalize+781 6: 00007FF78A9C268C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468 7: 00007FF78A9CF339 v8::internal::Heap::PublishPendingAllocations+1129 8: 00007FF78A9CC30A v8::internal::Heap::PageFlagsAreConsistent+2842 9: 00007FF78A9BEF89 v8::internal::Heap::CollectGarbage+2137 10: 00007FF78A9BD140 v8::internal::Heap::AllocateExternalBackingStore+2000 11: 00007FF78A9E1A76 v8::internal::Factory::NewFillerObject+214 12: 00007FF78A714CB5 v8::internal::DateCache::Weekday+1797 13: 00007FF78ABC2541 v8::internal::SetupIsolateDelegate::SetupHeap+494417 14: 000002BDD05E773E  ELIFECYCLE  Command failed with exit code 134.

so1ve commented 10 months ago

https://antfu.me/posts/why-reproductions-are-required-zh

Lionad-Morotar commented 9 months ago

[5164:000002BDCE4C8C60] 89310 ms: Scavenge (reduce) 2038.8 (2082.5) -> 2038.0 (2082.8) MB, 4.8 / 0.0 ms (average mu = 0.181, current mu = 0.054) allocation failure

楼主应该解决了吧,这是很典型的内存溢出错误。2G 内存上限在 2024 年前端来看属实不够用,我电脑里许多项目在编译的时候内存峰值都跑到了 4G,请更新 NodeJS,或增加内存上限再试试吧(2GB 内存报错应该是楼主并没有成功增加内存上限)。

ModyQyW commented 9 months ago
  1. Upgrade NodeJS (not sure required, but recomended)

  2. Increase your computer's memory limit (8G -> 16G, not required)

  3. Try cross-env NODE_OPTIONS=--max_old_space_size=4096 vue-tsc --build or cross-env NODE_OPTIONS=--max_old_space_size=4096 vue-tsc --noEmit --skipLibCheck (install cross-env yourself, set 4G memory, set larger for larger project)

  4. 升级 NodeJS(不确定是否必须,但非常建议)

  5. 增加电脑内存(8G -> 16G,不是必须的)

  6. 尝试 cross-env NODE_OPTIONS=--max_old_space_size=4096 vue-tsc --build 或者 cross-env NODE_OPTIONS=--max_old_space_size=4096 vue-tsc --noEmit --skipLibCheck(自行安装 cross-env,这里设置使用 4G 内存,对于更大的项目需要更大的内存)

hungify2022 commented 8 months ago

"typecheck": "vue-tsc --noEmit"

I have a problem with the lint-staged package, when I run the command npm run lint-staged the command npm run typecheck reports a types error, but when I run the command npm run typecheck it runs without any problem.

Besides: I have used vite-plugin-checker without any errors.

davidmatter commented 3 months ago

Closing this one as many things have changed since 2.x. Feel free to create a new issue with a minimal reproduction if you're still having issues, thanks!