1

我正在关注本教程(让 cloudflare 页面与动物 db 一起使用),但是当我进入“测试和部署 Worker”一章并尝试运行wrangler dev(它将运行npm run build,然后运行worktop build index.js)时,我收到错误消息sh: worktop: command not found.

我仔细检查了我是否正确执行了每个步骤,检查worktop了目录中是否存在node_modules(它是)并且还尝试worktop全局安装(不起作用)。

我在这里想念什么?

运行的完整输出wrangler dev

$ wrangler dev     
  Running npm run build

> fauna-demo-workers@1.0.0 build /Users/me/dev/fauna-demo-workers
> worktop build index.js

sh: worktop: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! fauna-demo-workers@1.0.0 build: `worktop build index.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the fauna-demo-workers@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2022-01-09T12_54_24_718Z-debug.log
Error: Build failed! Status Code: 1
4

1 回答 1

2

你必须安装worktop.build软件包。这就是worktop二进制文件的来源。名为“worktop”的包只是一个运行时库。不是每个人都想使用它自以为是的 CLI/builder,因此需要单独的包。

(我是worktop & worktop.build的作者)

于 2022-01-10T19:54:52.363 回答