'Cloudflare pages worker error when running wrangler dev
I'm following this tutorial (to get cloudflare pages working with fauna db), but when I get to the chapter "Testing and deploying the Worker" and try to run wrangler dev (which will run npm run build, which in turn runs worktop build index.js) I get the error message sh: worktop: command not found.
I have double checked that I have followed each step correctly, checked if worktop was present in the node_modules directory (it is) and also tried to install worktop globally (didn't work).
What am I missing here?
Full output of running wrangler dev:
$ wrangler dev
🌀 Running npm run build
> [email protected] 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! [email protected] build: `worktop build index.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] 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
Solution 1:[1]
you have to install the worktop.build package. That's where the worktop binary comes from. The package called “worktop” is just a runtime library. Not everyone will want to use its opinionated CLI/builder, hence the separate package.
(I'm the author of worktop & worktop.build)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | lukeed |
