spawn 提示 Error: spawn xxx ENOENT, exec 可以运行

文章讲述了在Node.js环境中,如何使用cross-spawn库来替代原生的spawn函数,以确保跨平台的兼容性和更好的错误处理。cross-spawn提供了一个方便的方式来执行外部命令,特别是在处理Windows和Unix系统差异时。
部署运行你感兴趣的模型镜像

改用 cross-spawn

const { spawn } = require("cross-spawn");

您可能感兴趣的与本文相关的镜像

GPT-oss:20b

GPT-oss:20b

图文对话
Gpt-oss

GPT OSS 是OpenAI 推出的重量级开放模型,面向强推理、智能体任务以及多样化开发场景

yarn pub:local yarn run v1.22.19 warning package.json: No license field $ cross-env HS_NODE_ENV=local node script/index.mjs ✔ 要发布的代码分支 - master 是否正确? Yes ✔ 请选择发布平台 移动端-Android ExecaError: Command failed with ENOENT: cli open spawn cli ENOENT at getFinalError (file:///Users/rui/Desktop/huasu/hs-lsms-app/node_modules/execa/lib/return/final-error.js:6:9) at makeError (file:///Users/rui/Desktop/huasu/hs-lsms-app/node_modules/execa/lib/return/result.js:108:16) at getAsyncResult (file:///Users/rui/Desktop/huasu/hs-lsms-app/node_modules/execa/lib/methods/main-async.js:168:4) at handlePromise (file:///Users/rui/Desktop/huasu/hs-lsms-app/node_modules/execa/lib/methods/main-async.js:151:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async publish (file:///Users/rui/Desktop/huasu/hs-lsms-app/script/platforms/android/index.mjs:44:3) { shortMessage: 'Command failed with ENOENT: cli open\nspawn cli ENOENT', originalMessage: 'spawn cli ENOENT', command: 'cli open', escapedCommand: 'cli open', cwd: '/Users/rui/Desktop/huasu/hs-lsms-app', durationMs: 13.519688, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, code: 'ENOENT', stdio: [ undefined, undefined, undefined ], ipcOutput: [], pipedFrom: [], [cause]: Error: spawn cli ENOENT at ChildProcess._handle.onexit (node:internal/child_process:286:19) at onErrorNT (node:internal/child_process:484:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn cli', path: 'cli', spawnargs: [ 'open' ] } } ✨ Done in 6.53s. ruideMacBook-Pro:hs-lsms-app rui$
08-20
=> [internal] load build context 0.7s => => transferring context: 77.36MB 0.6s => [stage-2 2/6] RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone 0.5s => [base-image 2/8] RUN echo "deb https://mirrors.aliyun.com/debian/ bookworm main non-free contrib" > /etc/apt/sources.list && echo "deb https://mirrors.aliyun.com/debian-security bookworm-security main non-free contrib" >> 0.5s => [stage-2 3/6] RUN rm -rf /app/superset/superset/static/dist 0.4s => [base-image 3/8] RUN apt-get update && apt-get install -y --no-install-recommends build-essential libssl-dev libffi-dev python3-dev libev-dev libjpeg-dev zlib1g-de 406.5s => [base-image 4/8] RUN apt-get remove -y nodejs npm || true 0.3s => [base-image 5/8] RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - 202.0s => [base-image 6/8] RUN apt-get update && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* 23.5s => [base-image 7/8] RUN corepack enable 0.3s => [base-image 8/8] RUN node --version && npm --version 0.3s => [frontend-builder 1/9] WORKDIR /app/superset-frontend 0.1s => [frontend-builder 2/9] COPY ./superset-5.0.0/superset-frontend/ . 0.4s => [frontend-builder 3/9] RUN ls -la && [ -f package.json ] || (echo "❌ Missing package.json!" && exit 1) && [ -f package-lock.json ] || (echo "❌ Missing package-lock.json!" && exit 1) 0.3s => [frontend-builder 4/9] RUN npm config set registry https://registry.npmmirror.com && mkdir -p /tmp/npm-cache && npm config set cache /tmp/npm-cache 1.7s => [frontend-builder 5/9] RUN --mount=type=cache,id=npm-node-modules,target=/app/superset-frontend/node_modules --mount=type=cache,id=npm-cache,target=/tmp/npm-cache npm ci 495.5s => [frontend-builder 6/9] RUN sed -i 's/cross-env/npx cross-env/g' package.json 0.4s => [frontend-builder 7/9] RUN echo "📁 Current directory:" && pwd && echo "📄 package.json exists:" && [ -f package.json ] && echo "✅" || echo "❌" && echo "📄 package-lock.json exists:" && [ -f package-lock.jso 0.6s => ERROR [frontend-builder 8/9] RUN npm run build && echo "✅ Frontend built successfully" 6.6s ------ > [frontend-builder 8/9] RUN npm run build && echo "✅ Frontend built successfully": 0.317 0.317 > superset@5.0.0 build 0.317 > npx cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=production BABEL_ENV="${BABEL_ENV:=production}" webpack --color --mode production 0.317 1.430 npm warn exec The following package was not found and will be installed: cross-env@10.1.0 6.523 node:events:502 6.523 throw er; // Unhandled 'error' event 6.523 ^ 6.523 6.523 Error: spawn webpack ENOENT 6.523 at ChildProcess._handle.onexit (node:internal/child_process:285:19) 6.523 at onErrorNT (node:internal/child_process:483:16) 6.523 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) 6.523 Emitted 'error' event on ChildProcess instance at: 6.523 at ChildProcess._handle.onexit (node:internal/child_process:291:12) 6.523 at onErrorNT (node:internal/child_process:483:16) 6.523 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { 6.523 errno: -2, 6.523 code: 'ENOENT', 6.523 syscall: 'spawn webpack', 6.523 path: 'webpack', 6.523 spawnargs: [ '--color', '--mode', 'production' ] 6.523 } 6.523 6.523 Node.js v20.19.5 ------ Dockerfile.superset:127 -------------------- 126 | # 构建前端生产包 127 | >>> RUN npm run build && \ 128 | >>> echo "✅ Frontend built successfully" 129 | -------------------- failed to solve: process "/bin/sh -c npm run build && echo \"✅ Frontend built successfully\"" did not complete successfully: exit code: 1 gapinyc@DESKTOP-9QS7RL5:~/superset-prod$
10-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值