Error: Cannot find module 'node:fs/promises'
abel-varga-ekata opened this issue · 5 comments
Description:
Cypress won't start up due to the titular error. The only plugin added in the config is cypress-image-snapshot
. Tried several NodeJS versions from 12.x.x to 20.x.x, but this seems to be irrelevant.
Versions:
OSX Ventura 13.4.1
Cypress v12.27.3
Cypress Image Snapshot v8.0.2
Full Stack Trace:
Error: Cannot find module 'node:fs/promises'
Require stack:
- /Users/avarga/pro-insight-development/proweb/node_modules/@simonsmith/cypress-image-snapshot/plugin.js
- /Users/avarga/pro-insight-development/proweb/cypress.config.ts
- /Users/avarga/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js
- /Users/avarga/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/avarga/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (/Users/avarga/pro-insight-development/proweb/node_modules/@simonsmith/cypress-image-snapshot/plugin.js:7:36)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (/Users/avarga/pro-insight-development/proweb/cypress.config.ts:2:1)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Module.m._compile (/Users/avarga/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:857:29)
at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Object.require.extensions. [as .ts] (/Users/avarga/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at loadFile (/Users/avarga/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:89:14)
Could you provide a reproducible example? You can clone this repo and run the tests here as one example. I'm pretty sure this is tightly related to the Node version. I'm having no trouble running this on node 18 both in this repository and others.
If I can find a way to create the error then I can assist. What version of node produced the error above?
Node 16 introduced the node:fs
syntax from what I can see here - https://nodejs.dev/en/api/v16/fs/
No mention of it in Node 14
Reference to the error here also details updating Node: https://stackoverflow.com/questions/71129905/error-cannot-find-module-nodefs-promises-next-sitemap
Thanks for getting back so quick. There is something really funky going on on my machine. Your repo throws Never mind, forgot to build probably. It results in the same error as the bug refers to.Error: Cannot find module './dist/plugin'
when I spin Cypress up.
Also I got this while installing:
The engine "node" is incompatible with this module. Expected version ">=v14.21.3". Got "14.17.5"
This leads me to think that n
did not in fact update the node
bin that yarn
uses. So this might be the root-cause of the issue.
My node version should by: v18.17.0 currently, by the way.
Yes! I had yarn
installed from nix-pkgs
and that binary used it's own outdated node version. So the issue was on my end. Thanks for addressing it though!
Cheers!
Excellent, glad you solved!