zchr
zchr
CDCloudflare Developers
Created by zchr on 11/22/2023 in #pages-help
Nodejs_compat in Page Functions
Howdy all, I'm trying to deploy TinaCMS (https://github.com/tinacms/tinacms) self-hosted (https://tina.io/docs/reference/self-hosted/database-adapter/overview/) on Pages using Workers KV. | I set up a functions/graphql.ts to handle a graphql endpoint that imports some nodejs specific libraries from Tina. The deployments failed for it. There was a hint given by the error messages to add nodejs_compat as a compatiblity flag which I proceed to do in the Dashboard for both preview and prodution deployments but this did not seem to change when I retried the deployment. Similarly wrangler pages dev ./out --compatibility-date 21-11-2023 --compatibility-flags nodejs_compat does not seem to work end gives me the same error:
.....
✘ [ERROR] Could not resolve "path"

../node_modules/picomatch/lib/utils.js:3:21:
3 │ const path = require('path');
╵ ~~~~~~

The package "path" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project to enable Node.js compatibility.


✘ [ERROR] Could not resolve "crypto"

../node_modules/scmp/index.js:3:23:
3 │ const crypto = require('crypto')
╵ ~~~~~~~~

The package "crypto" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project to enable Node.js compatibility.


✘ [ERROR] Build failed with 53 errors:

../node_modules/@iarna/toml/parse-stream.js:4:23: ERROR: Could not resolve "stream"
../node_modules/@nodelib/fs.scandir/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
../node_modules/@nodelib/fs.scandir/out/settings.js:3:21: ERROR: Could not resolve "path"
../node_modules/@nodelib/fs.stat/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
../node_modules/@nodelib/fs.walk/out/providers/stream.js:3:25: ERROR: Could not resolve "stream"
...
.....
✘ [ERROR] Could not resolve "path"

../node_modules/picomatch/lib/utils.js:3:21:
3 │ const path = require('path');
╵ ~~~~~~

The package "path" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project to enable Node.js compatibility.


✘ [ERROR] Could not resolve "crypto"

../node_modules/scmp/index.js:3:23:
3 │ const crypto = require('crypto')
╵ ~~~~~~~~

The package "crypto" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project to enable Node.js compatibility.


✘ [ERROR] Build failed with 53 errors:

../node_modules/@iarna/toml/parse-stream.js:4:23: ERROR: Could not resolve "stream"
../node_modules/@nodelib/fs.scandir/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
../node_modules/@nodelib/fs.scandir/out/settings.js:3:21: ERROR: Could not resolve "path"
../node_modules/@nodelib/fs.stat/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
../node_modules/@nodelib/fs.walk/out/providers/stream.js:3:25: ERROR: Could not resolve "stream"
...
Any hints?
5 replies