https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • j

    jacob9706

    11/24/2021, 7:35 PM
    Hey everyone, I seem to be running into an issue with CF Pages build ENV not finding NPM "binaries", has anyone else ran into this? Specifically NPM postinstall scripts that reference installed NPM packages fail with a not found message: https://dash.cloudflare.com/574fdb1eae7e80782a805c4b92f6b626/pages/view/remix-cloudflare-pages/1442ecfc-7966-47a4-b6d4-9ad308251413 Any assistance or insight into how to inspect the state of the build env would be much appreciated.
  • j

    jacob9706

    11/24/2021, 8:13 PM
    Here is a PR to address static asset handling issues for pages in wrangler v2: https://github.com/cloudflare/wrangler2/pull/46
  • u

    0xDamian

    11/24/2021, 10:53 PM
    Linking your dashboard panel as you know doesn't help anyone. You posted a issue with static files, you know that you upload the static files to pages and you don't need any workers for that right?
  • u

    0xDamian

    11/24/2021, 10:54 PM
    All you need is to connect your Github repo and deploy it, that's all. All the static files are served automatically and they are extremely fast.
  • w

    William | Chaos Management

    11/24/2021, 11:00 PM
    I don't think you understand how pages functions works when testing locally
  • j

    jacob9706

    11/24/2021, 11:00 PM
    Was hopeful it would be useful for someone at cloudflare. I'm well aware of how static files work. The issue I posted was around the build step not being able to use installed npm module binaries to build the static files and _worker.js script. The subsequent message is a different thing addressing an issue with wranger@v2
    wrangler pages dev
    command.
  • w

    William | Chaos Management

    11/24/2021, 11:00 PM
    to test pages functions locally you need wrangler
  • j

    jacob9706

    11/24/2021, 11:02 PM
    Issue is in CF pages build environment that runs when you push to a repo, nothing to do with local.
  • w

    William | Chaos Management

    11/24/2021, 11:02 PM
    I was talking to @User about what he said
  • w

    William | Chaos Management

    11/24/2021, 11:03 PM
    in the pages logs though, what does it show when it says not found?
  • j

    jacob9706

    11/24/2021, 11:07 PM
    Copy code
    11:42:07.200    Installing NPM modules using NPM version 8.1.0
    11:42:10.628    
    11:42:10.629    > postinstall
    11:42:10.629    > remix setup cloudflare-workers
    11:42:10.629    
    11:42:10.640    sh: 1: remix: not found
    11:42:10.643    npm ERR! code 127
    11:42:10.643    npm ERR! path /opt/buildhome/repo
    11:42:10.645    npm ERR! command failed
    11:42:10.645    npm ERR! command sh -c remix setup cloudflare-workers
  • w

    William | Chaos Management

    11/24/2021, 11:08 PM
    did you install remix using npm?
  • j

    jacob9706

    11/24/2021, 11:08 PM
    This is a dev dependency, do you know if they install only production deps?
  • w

    William | Chaos Management

    11/24/2021, 11:09 PM
    I would try and modify the post install script to use
    npx remix setup cloudflare-workers
  • w

    William | Chaos Management

    11/24/2021, 11:09 PM
    see if that makes a difference
  • w

    William | Chaos Management

    11/24/2021, 11:09 PM
    and npm should be installing all of your dependencies
  • j

    jacob9706

    11/24/2021, 11:22 PM
    For anyone else who runs into this issue, setting NODE_ENV=production in the CF Pages UX causes the CI to only install production dependencies. Makes sense and I overlooked it.
  • w

    William | Chaos Management

    11/24/2021, 11:23 PM
    oh yeah that makes sense
  • c

    chrisjmccreadie

    11/25/2021, 4:36 PM
    hay, I have a question. when I run my pages locally using the command below: npx wrangler pages dev functions it does not see the name KV variable I set the settings of the page. Am I missing something obvious?
  • o

    oliverjam

    11/25/2021, 7:28 PM
    I think you need to set bindings for KV/env variables manually for local development:
    Copy code
    npx wrangler pages dev functions --KV MY_KV
  • c

    chrisjmccreadie

    11/25/2021, 7:31 PM
    yeah, i tried that i get it as undefined
  • c

    chrisjmccreadie

    11/25/2021, 7:31 PM
    i also tried to use namespace_id and bindings
  • e

    eidam | SuperSaaS

    11/26/2021, 12:01 PM
    @User yes, moving the middleware file to the top will make it trigger on each request
  • t

    The Freelancer ;)

    11/26/2021, 12:02 PM
    thank you 😄
  • e

    eidam | SuperSaaS

    11/26/2021, 12:02 PM
    I am just not sure now what is the right way to configure Functions to trigger on
    /
    as well, if you find out please let me know
  • e

    eidam | SuperSaaS

    11/26/2021, 12:04 PM
    right https://developers.cloudflare.com/pages/platform/functions#middleware-routing
  • t

    The Freelancer ;)

    11/26/2021, 12:05 PM
    that makes sense
  • t

    The Freelancer ;)

    11/26/2021, 12:05 PM
    that's what I was going to try 😄
  • t

    The Freelancer ;)

    11/26/2021, 12:06 PM
    thing is, once I get it working with one site it will be easy 😄
  • t

    The Freelancer ;)

    11/26/2021, 12:07 PM
    let me quickly create a new GitLab project to try it 🙂
1...202122...392Latest