Summary
用 bun 运行 JavaScript / TypeScript 脚本的环境规则:一律优先用 bun 命令执行,bun 原生支持 .js 和 .ts,import 的第三方依赖自动下载安装,无需 package.json 和任何依赖声明步骤;禁止 node/npm/yarn/pnpm 等替代方式执行,禁止 npm…
lanyuanxiaoyao/skills · Archived
用 bun 运行 JavaScript / TypeScript 脚本的环境规则:一律优?
npx skills add lanyuanxiaoyao/skills --skill lyxy-runner-javascript
用 bun 运行 JavaScript / TypeScript 脚本的环境规则:一律优先用 bun 命令执行,bun 原生支持 .js 和 .ts,import 的第三方依赖自动下载安装,无需 package.json 和任何依赖声明步骤;禁止 node/npm/yarn/pnpm 等替代方式执行,禁止 npm…
This repository is archived — consider an actively maintained alternative.
统一文档解析工具 - 将 DOC、DOCX、XLS、XLSX、PPT、PPTX、PDF、HTML/URL 转换为 Markdown。支持全文…
91 installs用 uv 运行 Python 脚本的环境规则:一律优先 uv,依赖免预装、不污染系统 Python。自己写的临时脚本…
4 installsAny task that requires Javascript/Typescript processing should use this skill.
2 installsRelated neighbors and high-traction skills in the same topics — useful to compare before installing.
Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies…
12.6K installsRivetKit JavaScript client guidance. Use for browser, Node.js, or Bun clients that connect to R…
7.6K installsWrite JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json…
6.3K installsWrites, debugs, and refactors JavaScript code using modern ES2023+ features, async/await patter…
5.1K installsOther skills from lanyuanxiaoyao/skills.
npx skills add lanyuanxiaoyao/skills
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
main
Parsed from SKILL.md frontmatter.
Files included with this skill beyond the listing page.
SKILL.md
4,392 B
SUMMARY.md
529 B
以下为全部规则,无引用文件。
bun <script_path>。bun 原生支持 .js / .ts / .mjs,TypeScript 直接执行,无编译步骤。command not found: bun):立即停止任务,告知用户安装 bun(https://bun.sh ,Windows:powershell -c "irm bun.sh/install.ps1 | iex",macOS/Linux:curl -fsSL https://bun.sh/install | bash),等待用户安装后再继续。不自动安装(全局安装须用户确认),不退回替代工具,不建议把脚本转成其他运行时格式。npm install / bun add 等手动装包;禁止往主机装全局包。import 的依赖由 bun 自动处理。import / require 的第三方包,bun 首次运行时自动从 npm 下载并缓存(~/.bun/install/cache),后续走缓存。无 package.json、无 bun install、无任何声明步骤,默认最新版。import)和 CommonJS(require)都支持,优先 ESM。仅临时脚本场景强制 bun。进入具体项目:
bun <scriptpath>,依赖来自项目 nodemodulesbun add / npm install 装依赖(装依赖须用户明确要求并按项目约定)自写临时脚本一律放系统临时目录(Windows %TEMP%,Git Bash /tmp),文件名带前缀(如 lyxy-runner-javascript-*.ts)便于清理;不放当前工作目录,除非用户指定。执行后不主动删除:系统自管临时目录,保留便于调试。
| 场景 | 命令 |
|---|---|
| 执行已有脚本(.js/.ts 均可) | bun <script_path> |
| 自写临时脚本 | 写入系统临时目录 → bun <temp_path> |
| 用户指定路径创建脚本 | 写入指定路径 → bun <path> |
| 错误 | 处理 |
|---|---|
command not found: bun |
停止任务,按"核心规则"引导安装,等待用户 |
| 语法错误 | bun 输出含文件路径、行列号和位置指示,按提示修复后重试 |
| 运行时错误(ReferenceError 等) | bun 输出完整堆栈跟踪,按堆栈定位修复 |
| 模块找不到(Cannot find module) | 项目目录内:缺依赖,与用户确认后按项目约定装;临时目录内:检查 import 拼写 |
输出处理:console.log / info / warn → stdout;console.error → stderr(2> 单独捕获);退出码 process.exit(0|1) 表示成败。
执行已有 TypeScript 脚本(无需编译):
bun ./scripts/my-script.ts
自写临时脚本:写入 /tmp/lyxy-runner-javascript-stars.ts 后执行 bun /tmp/lyxy-runner-javascript-stars.ts:
import axios from 'axios'; // 首次运行自动安装,无需任何声明
const resp = await axios.get('https://api.github.com/repos/oven-sh/bun');
console.log(`Stars: ${resp.data.stargazers_count}`);
bun <script_path> 执行;出错按"常见错误"处理