【】js不同颜色(TypeScript 编译篇);反射+插件Mgr+Nodejs+VSCode_Debug

📅 2026/8/26 13:48:26
【】js不同颜色(TypeScript 编译篇);反射+插件Mgr+Nodejs+VSCode_Debug
说 JS/TS 统一天下的请先把环境统一一下第一句没绷住必须编译浏览器不能直接运行 TypeScript (.ts) 文件。浏览器只识别 JavaScript不认识 TS 的语法、类型注解。我先检查这个子项目的package.json、锁文件、npm 配置以及当前安装进程状态重点区分是依赖源连接问题、某个包下载停滞还是脚本阶段卡住。随后会用一个最小网络/解析检查来验证判断。Get-ChildItem -Force .\Assets\3DMeshes\threejs-grass-water-shaders-main | Select-Object Name,Length,LastWriteTimeGet-Content .\Assets\3DMeshes\threejs-grass-water-shaders-main\package.jsonGet-ChildItem Env: | Where-Object { $_.Name -match ^(npm|http|https|no_proxy) } | Sort-Object Name | Format-Table -AutoSizeGet-Process node,npm -ErrorAction SilentlyContinue | Select-Object Id,ProcessName,CPU,StartTime,PathPush-Location .\Assets\3DMeshes\threejs-grass-water-shaders-main; npm config get registry; npm config get proxy; npm config get https-proxy; npm config get cache; Pop-Location唯一这段获取git可能复制不全代码有问题大概意思懂了就行了就是处理 git 的代码库依赖rg -n resolved|registry|git\|github.com|codeload .\Assets\3DMeshes\threejs-grass-water-shaders-main\package-lock.json | Select-Object -First 30Push-Location .\Assets\3DMeshes\threejs-grass-water-shaders-main; npm cache verify; Pop-LocationTest-NetConnection registry.npmjs.org -Port 443; Test-NetConnection registry.npmmirror.com -Port 443问题原因关键证据已经明确当前 npm registry 是https://registry.npmjs.org/但本机对它 DNS 解析失败registry.npmmirror.com的 443 端口可达。锁文件又把大量 tarball 的resolved地址固定为registry.npmjs.org所以即使依赖缓存存在安装仍可能在访问 npmjs 时表现为“卡住”。我再做一次本地依赖完整性检查并确认是否能完全离线完成安装。$root .\Assets\3DMeshes\threejs-grass-water-shaders-main; $lock Get-Content $root\package-lock.json -Raw | ConvertFrom-Json; [pscustomobject]{LockPackages$lock.packages.PSObject.Properties.Count; NodeModulesDirs(Get-ChildItem $root\node_modules -Directory -ErrorAction SilentlyContinue).Count; LockfileVersion$lock.lockfileVersion} | Format-List最终解决方法npm install --registryhttps://registry.npmmirror.com --fetch-timeout30000 --fetch-retries1解决了个寂寞如解决了自己看去吧无厘头参考TSTypescript 反射4种调用方法概要方法一二方法三decorator方法四反射nodeJs调试Visual Studio Code · Node.js 调试指南 (gitbooks.io)参考来源TypeScript: Documentation - Decorators (typescriptlang.org)TypeScript 动态调用实例方法的方法|极客笔记 (deepinout.com)TypeScript中有何方法能够做到反射 - 知乎 (zhihu.com)在 TypeScript 中删除一个数组项 | D栈 - Delft Stack