cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.64k stars 690 forks source link

Pages cloud not resolve node core module `perf_hooks` #174

Closed willin closed 2 years ago

willin commented 2 years ago
yarn run v1.22.17
$ cross-env NODE_ENV=development run-p dev:*
$ remix watch
$ npm run build:css -- --w
$ wrangler pages dev ./public --watch ./build

> build:css
> postcss styles/**/*.css --base styles --dir app/styles "--w"

Watching Remix app in development mode...
💿 Built in 152ms

warn - The `purge`/`content` options have changed in Tailwind CSS v3.0.
warn - Update your configuration file to eliminate this warning.
Compiling worker to "/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js"
✘ [ERROR] Could not resolve "perf_hooks"

    build/index.js:86:28:
      86 │ import { performance } from "perf_hooks";
         ╵                             ~~~~~~~~~~~~

  The package "perf_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

/Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1493
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
build/index.js:86:28: ERROR: Could not resolve "perf_hooks"
    at failureErrorWithLog (/Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1493:15)
    at /Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1151:28
    at runOnEndCallbacks (/Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1069:65)
    at buildResponseToResult (/Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1149:7)
    at /Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1258:14
    at /Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/Users/v0/Sites/poc/my-remix-app/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:596:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:324:12) {
  errors: [
    {
      detail: undefined,
      location: {
        column: 28,
        file: 'build/index.js',
        length: 12,
        line: 86,
        lineText: 'import { performance } from "perf_hooks";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: `The package "perf_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.`
        }
      ],
      pluginName: '',
      text: 'Could not resolve "perf_hooks"'
    }
  ],
  warnings: []
}

Node.js v17.2.0
wrangler pages dev [directory] [-- command]

🧑‍💻 Develop your full-stack Pages application locally

Positionals:
  directory  The directory of static assets to serve  [string]
  command    The proxy command to run  [string]

Flags:
  -c, --config   Path to .toml configuration file  [string]
  -h, --help     Show help  [boolean]
  -v, --version  Show version number  [boolean]

Options:
  -l, --local        Run on my machine  [boolean] [default: true]
      --port         The port to listen on (serve from)  [number] [default: 8788]
      --proxy        The port to proxy (where the static assets are served)  [number]
      --script-path  The location of the single Worker script if not using functions  [string] [default: "_worker.js"]
  -b, --binding      Bind variable/secret (KEY=VALUE)  [array]
  -k, --kv           KV namespace to bind  [array]
  -o, --do           Durable Object to bind (NAME=CLASS)  [array]

BuildError [1]: Build failed with exit code 1
    at ChildProcess.<anonymous> (/Users/v0/Sites/poc/my-remix-app/node_modules/@miniflare/core/src/plugins/build.ts:73:25)
    at ChildProcess.emit (node:events:390:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  code: 1,
  cause: undefined
}
/Users/v0/Sites/poc/my-remix-app/node_modules/wrangler/wrangler-dist/cli.js:27072
            throw ex;
            ^

BuildError [1]: Build failed with exit code 1
    at ChildProcess.<anonymous> (/Users/v0/Sites/poc/my-remix-app/node_modules/@miniflare/core/src/plugins/build.ts:73:25)
    at ChildProcess.emit (node:events:390:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  code: 1,
  cause: undefined
}

Node.js v17.2.0
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "dev:wrangler" exited with 7.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
willin commented 2 years ago

besides. process is not defined too.

warn - The `purge`/`content` options have changed in Tailwind CSS v3.0.
warn - Update your configuration file to eliminate this warning.
Compiling worker to "/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js"
Finished in 55ms.
wrangler pages dev [directory] [-- command]

🧑‍💻 Develop your full-stack Pages application locally

Positionals:
  directory  The directory of static assets to serve  [string]
  command    The proxy command to run  [string]

Flags:
  -c, --config   Path to .toml configuration file  [string]
  -h, --help     Show help  [boolean]
  -v, --version  Show version number  [boolean]

Options:
  -l, --local        Run on my machine  [boolean] [default: true]
      --port         The port to listen on (serve from)  [number] [default: 8788]
      --proxy        The port to proxy (where the static assets are served)  [number]
      --script-path  The location of the single Worker script if not using functions  [string] [default: "_worker.js"]
  -b, --binding      Bind variable/secret (KEY=VALUE)  [array]
  -k, --kv           KV namespace to bind  [array]
  -o, --do           Durable Object to bind (NAME=CLASS)  [array]

ReferenceError: process is not defined
    at env (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19498:17)
    at isProduction (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19504:10)
    at build/index.js (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19616:17)
    at __init (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:9:50)
    at functions/[[path]].js (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19774:5)
    at __init (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:9:50)
    at ../../../../../var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/plinko-ZWdvUa/routes.mjs (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19785:5)
    at __init (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:9:50)
    at /var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19798:1
    at SourceTextModule.evaluate (node:internal/vm/module:224:23)
[pages:err] Unhandled Promise Rejection: ReferenceError: process is not defined
    at env (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19498:17)
    at isProduction (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19504:10)
    at build/index.js (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19616:17)
    at __init (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:9:50)
    at functions/[[path]].js (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19774:5)
    at __init (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:9:50)
    at ../../../../../var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/plinko-ZWdvUa/routes.mjs (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19785:5)
    at __init (/var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:9:50)
    at /var/folders/td/zr87rwn546n4q0y3zddn95zw0000gn/T/functionsWorker.js:19798:1
    at SourceTextModule.evaluate (node:internal/vm/module:224:23)
💿 File changed: app/root.tsx
💿 File changed: app/services/theme.server.ts
💿 Rebuilding...
GregBrimble commented 2 years ago

Closing as dupe of #1074.