Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: ENOENT: no such file or directory, open '[MONOREPO_ROOT]/web/.worker-next/.next/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js' #148

Open
Benjamin-Dobell opened this issue Nov 29, 2024 · 4 comments
Labels
bug Something isn't working needs repro

Comments

@Benjamin-Dobell
Copy link

Benjamin-Dobell commented Nov 29, 2024

Describe the bug

Unable to build. Errors out with:

node:fs:441
    return binding.readFileUtf8(path, stringToFlags(options.flag));
                   ^

Error: ENOENT: no such file or directory, open '[MONOREPO_ROOT]/web/.worker-next/.next/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js'
    at readFileSync (node:fs:441:20)
    at patchWranglerDeps (file://[MONOREPO_ROOT]/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@opennextjs/cloudflare/dist/cli/index.mjs:7058:31)
    at buildWorker (file://[MONOREPO_ROOT]/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@opennextjs/cloudflare/dist/cli/index.mjs:7223:3)
    at async build3 (file://[MONOREPO_ROOT]/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@opennextjs/cloudflare/dist/cli/index.mjs:7346:3)
    at async file://[MONOREPO_ROOT]/node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@opennextjs/cloudflare/dist/cli/index.mjs:7417:1 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/web/.worker-next/.next/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js'
}

This is fairly similar to #42.

Contents of the target compiled directory are just:

ls -la [MONOREPO_ROOT]/web/.worker-next/.next/standalone/node_modules/next/dist/compiled/
total 0
drwxr-xr-x  3 ben  staff   96 30 Nov 00:08 .
drwxr-xr-x  5 ben  staff  160 30 Nov 00:08 ..
drwxr-xr-x  4 ben  staff  128 30 Nov 00:08 jest-worker

However, the standalone compiled directory from in the monorepo root seems to contain the files we're after:

ls -la [MONOREPO_ROOT]/node_modules/next/dist/compiled/ 
total 0
drwxr-xr-x  144 ben  staff  4608 29 Nov 22:36 .
drwxr-xr-x   19 ben  staff   608 29 Nov 22:36 ..
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 @ampproject
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 @babel
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 @edge-runtime
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 @hapi
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 @mswjs
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 @napi-rs
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 @next
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 @opentelemetry
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 @vercel
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 acorn
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 amphtml-validator
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 anser
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 arg
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 assert
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 async-retry
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 async-sema
drwxr-xr-x   32 ben  staff  1024 29 Nov 22:36 babel
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 babel-packages
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 browserify-zlib
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 browserslist
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 buffer
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 bytes
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 ci-info
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 cli-select
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 client-only
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 commander
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 comment-json
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 compression
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 conf
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 constants-browserify
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 content-disposition
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 content-type
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 cookie
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 cross-spawn
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 crypto-browserify
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 css.escape
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 cssnano-simple
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 data-uri-to-buffer
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 debug
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 devalue
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 domain-browser
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 edge-runtime
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 events
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 find-cache-dir
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 find-up
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 fresh
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 get-orientation
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 glob
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 gzip-size
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 http-proxy
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 http-proxy-agent
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 https-browserify
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 https-proxy-agent
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 icss-utils
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 ignore-loader
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 image-size
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 is-animated
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 is-docker
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 is-wsl
drwxr-xr-x    7 ben  staff   224 29 Nov 22:36 jest-worker
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 json5
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 jsonwebtoken
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 loader-runner
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 loader-utils2
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 loader-utils3
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 lodash.curry
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 lru-cache
drwxr-xr-x    8 ben  staff   256 29 Nov 22:36 mini-css-extract-plugin
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 nanoid
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 native-url
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 neo-async
drwxr-xr-x   40 ben  staff  1280 29 Nov 22:36 next-server
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 node-fetch
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 node-html-parser
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 ora
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 os-browserify
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 p-limit
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 path-browserify
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 path-to-regexp
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 picomatch
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 platform
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-flexbugs-fixes
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-modules-extract-imports
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-modules-local-by-default
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-modules-scope
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-modules-values
drwxr-xr-x    3 ben  staff    96 29 Nov 22:36 postcss-plugin-stub-for-cssnano-simple
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 postcss-preset-env
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-safe-parser
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-scss
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 postcss-value-parser
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 process
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 punycode
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 querystring-es3
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 raw-body
drwxr-xr-x   10 ben  staff   320 29 Nov 22:36 react
drwxr-xr-x   15 ben  staff   480 29 Nov 22:36 react-dom
drwxr-xr-x   15 ben  staff   480 29 Nov 22:36 react-dom-experimental
drwxr-xr-x   10 ben  staff   320 29 Nov 22:36 react-experimental
drwxr-xr-x    8 ben  staff   256 29 Nov 22:36 react-is
drwxr-xr-x    8 ben  staff   256 29 Nov 22:36 react-refresh
drwxr-xr-x   17 ben  staff   544 29 Nov 22:36 react-server-dom-turbopack
drwxr-xr-x   17 ben  staff   544 29 Nov 22:36 react-server-dom-turbopack-experimental
drwxr-xr-x   18 ben  staff   576 29 Nov 22:36 react-server-dom-webpack
drwxr-xr-x   18 ben  staff   576 29 Nov 22:36 react-server-dom-webpack-experimental
drwxr-xr-x    7 ben  staff   224 29 Nov 22:36 regenerator-runtime
drwxr-xr-x    6 ben  staff   192 29 Nov 22:36 sass-loader
drwxr-xr-x    9 ben  staff   288 29 Nov 22:36 scheduler
drwxr-xr-x    9 ben  staff   288 29 Nov 22:36 scheduler-experimental
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 schema-utils2
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 schema-utils3
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 semver
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 send
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 server-only
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 setimmediate
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 shell-quote
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 source-map
drwxr-xr-x    6 ben  staff   192 29 Nov 22:36 source-map08
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 stacktrace-parser
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 stream-browserify
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 stream-http
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 string-hash
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 string_decoder
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 strip-ansi
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 superstruct
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 tar
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 terser
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 text-table
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 timers-browserify
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 tty-browserify
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 ua-parser-js
drwxr-xr-x    4 ben  staff   128 29 Nov 22:36 unistore
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 util
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 vm-browserify
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 watchpack
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 web-vitals
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 web-vitals-attribution
drwxr-xr-x   29 ben  staff   928 29 Nov 22:36 webpack
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 webpack-sources1
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 webpack-sources3
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 ws
drwxr-xr-x    5 ben  staff   160 29 Nov 22:36 zod

This is a PNPM workspace.

Steps to reproduce

  1. Create a PNPM workspace.
  2. Setup a Next.js project with OpenNext cloudflare project in an sub-directory. You could probably just clone an example.
  3. Install dependencies.
  4. In the sub-directory with the Next.js project execute pnpm exec cloudflare.

Expected behavior

Build should succeed without errors.

@opennextjs/cloudflare version

0.2.1 / https://pkg.pr.new/@opennextjs/cloudflare@main

Node.js version

22.x

Wrangler version

3.91.0

next info output

Node.js v22.11.0

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.12.3
Relevant Packages:
  next: 14.2.10 // An outdated version detected (latest is 15.0.3), upgrade is highly recommended!
  eslint-config-next: 14.2.18
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 4.9.5
Next.js Config:
  output: standalone
 ⚠ An outdated version detected (latest is 15.0.3), upgrade is highly recommended!
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

Additional context

No response

@Benjamin-Dobell Benjamin-Dobell added bug Something isn't working triage labels Nov 29, 2024
@Benjamin-Dobell
Copy link
Author

Oh, in my stacktrace above it shows I've patched @opennextjs/cloudflare. This was done after running into this to introduce some logging. The output of which is my config:

patchWranglerDeps - config = {
  "build": {
    "timestamp": 1732886590021,
    "skipNextBuild": false,
    "shouldMinify": true
  },
  "paths": {
    "sourceDir": "[MONOREPO_ROOT]/web",
    "outputDir": "[MONOREPO_ROOT]/web/.worker-next",
    "dotNext": "[MONOREPO_ROOT]/web/.worker-next/.next",
    "standaloneRoot": "[MONOREPO_ROOT]/web/.worker-next/.next/standalone",
    "standaloneApp": "[MONOREPO_ROOT]/web/.worker-next/.next/standalone",
    "standaloneAppDotNext": "[MONOREPO_ROOT]/web/.worker-next/.next/standalone/.next",
    "standaloneAppServer": "[MONOREPO_ROOT]/web/.worker-next/.next/standalone/.next/server",
    "internalPackage": "[MONOREPO_ROOT]/web/.worker-next/.next/standalone/node_modules/@opennextjs/cloudflare",
    "internalTemplates": "[MONOREPO_ROOT]/web/.worker-next/.next/standalone/node_modules/@opennextjs/cloudflare/cli/templates"
  },
  "cache": {
    "kvBindingName": "NEXT_CACHE_WORKERS_KV"
  },
  "internalPackageName": "@opennextjs/cloudflare"
}

@vicb vicb added needs repro and removed triage labels Dec 2, 2024
@vicb
Copy link
Contributor

vicb commented Dec 2, 2024

Please attach a repro in a GH repository, thanks.

Benjamin-Dobell added a commit to Benjamin-Dobell/opennext-cloudflare-bug that referenced this issue Dec 2, 2024
@Benjamin-Dobell
Copy link
Author

Thanks for taking a look.

Repository: https://github.com/Benjamin-Dobell/opennext-cloudflare-bug

Quick (1 m 30s) video creating the contents of the repository from scratch:

CleanShot.2024-12-02.at.21.03.32.mp4

@hach-que
Copy link

hach-que commented Jan 3, 2025

I am also running into this with Yarn (potentially due to Plug 'n' Play):

# copyPackageTemplateFiles
node:internal/fs/cp/cp-sync:56
  fsBinding.cpSyncCheckPaths(src, dest, opts.dereference, opts.recursive);
            ^
Error: ENOENT: no such file or directory, lstat '/__w/website/website/.yarn/__virtual__/@opennextjs-cloudflare-virtual-ba5a08b239/4/github/home/.yarn/berry/cache/@opennextjs-cloudflare-npm-0.3.3-1aa47623ab-10c0.zip/node_modules/@opennextjs/cloudflare/dist/cli'
    at cpSyncFn (node:internal/fs/cp/cp-sync:56:13)
    at Object.cpSync (node:fs:3046:3)
    at Module.copyPackageCliFiles (file:///__w/website/website/.yarn/__virtual__/@opennextjs-cloudflare-virtual-ba5a08b239/4/github/home/.yarn/berry/cache/@opennextjs-cloudflare-npm-0.3.3-1aa47623ab-10c0.zip/node_modules/@opennextjs/cloudflare/dist/cli/build/patches/investigated/copy-package-cli-files.js:11:8)
    at bundleServer (file:///__w/website/website/.yarn/__virtual__/@opennextjs-cloudflare-virtual-ba5a08b239/4/github/home/.yarn/berry/cache/@opennextjs-cloudflare-npm-0.3.3-1aa47623ab-10c0.zip/node_modules/@opennextjs/cloudflare/dist/cli/build/bundle-server.js:13:13)
    at build (file:///__w/website/website/.yarn/__virtual__/@opennextjs-cloudflare-virtual-ba5a08b239/4/github/home/.yarn/berry/cache/@opennextjs-cloudflare-npm-0.3.3-1aa47623ab-10c0.zip/node_modules/@opennextjs/cloudflare/dist/cli/build/index.js:78:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async file:///__w/website/website/.yarn/__virtual__/@opennextjs-cloudflare-virtual-ba5a08b239/4/github/home/.yarn/berry/cache/@opennextjs-cloudflare-npm-0.3.3-1aa47623ab-10c0.zip/node_modules/@opennextjs/cloudflare/dist/cli/index.js:7:1 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/__w/website/website/.yarn/__virtual__/@opennextjs-cloudflare-virtual-ba5a08b239/4/github/home/.yarn/berry/cache/@opennextjs-cloudflare-npm-0.3.3-1aa47623ab-10c0.zip/node_modules/@opennextjs/cloudflare/dist/cli'
}
Node.js v22.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs repro
Projects
None yet
Development

No branches or pull requests

3 participants