sst / ion

SST v3
https://sst.dev
MIT License
1.83k stars 220 forks source link

Error in sst dev Command: Could not resolve "path-to-regexp" #710

Open tothgBudapest opened 2 months ago

tothgBudapest commented 2 months ago

I'm encountering an error when running the sst dev command in my Next.js project using the Serverless Stack (SST). The error message indicates that the path-to-regexp module could not be resolved. Below are the details:

tothgergo@Toth-MacBook-Pro:~/Projects/demo-ion-nextjs|⇒  npm run dev

> demo-ion-nextjs@0.1.0 dev
> sst dev next dev

SST ❍ ion 0.0.542  ready!

➜  App:        demo-ion-nextjs
   Stage:      tothgergo
   Console:    https://console.sst.dev/local/demo-ion-nextjs/tothgergo

~  Deploying

|  Error       .sst/platform/src/components/cloudflare/remix.ts:3:29: Could not resolve "path-to-regexp"

Environment:

OS: macOS Node.js version: 22.5.0 npm version: 10.8.2 SST version: 0.0.542

Expected Behavior: The development server should start without any errors, and the application should be deployed successfully.

Actual Behavior: The deployment fails with the error: "Could not resolve 'path-to-regexp'".

ZachLegros commented 2 months ago

+1

thdxr commented 2 months ago

does wiping the .sst folder fix this?

jayair commented 2 months ago

@tothgBudapest can I see your sst.config.ts? I'm confused why the Cloudlfare Remix component is involved here.

balintant commented 2 months ago

👋

@jayair actually it is an issue with Yarn 4 it seems. No matter if nodeLinker is set to node-modules vs. pnp. We are using yarn through corepack. Using pnpm instead of yarn works just fine.

@thdxr no it doesn't make a difference. See ^

jaapmvermeer commented 1 month ago

I am also getting this error, please advise how to resolve

balintant commented 1 month ago

@jaapmvermeer what package manager do you use?

jaapmvermeer commented 1 month ago

npm@10.8.2 node v22.5.1

balintant commented 1 month ago

We didn't have the issue with npm or pnpm, only yarn. 🙁 Do you have the issue with the base configuration? Have you modified anything? (Can you share config / output?)

jaapmvermeer commented 1 month ago

thanks for looking into this. I am basically trying to follow the sst guide:

  1. clone https://github.com/sst/monorepo-template
  2. change app name to notes
  3. npm install:
image
  1. make the changes to infra/api.ts ,infra/storage.ts, packages/functions/src/api.ts
  2. update sst.config.ts image

start the dev environment: npx sst dev

image

then I try npm audit fix

image

but give other error when starting npx sst dev

image
balintant commented 1 month ago

@jaapmvermeer There's a bug with Node 22.5 (see https://github.com/nodejs/node/pull/53934). Let me know if it works with 22.4.* or earlier. (I'm not sure if this specific issue is related, but we had some weirdnesses that otherwise seemed unrelated.)

jaapmvermeer commented 1 month ago

tried with 21.7.3 and have same results. I noticed another error in the log file:

time=2024-08-08T08:52:39.834-04:00 level=ERROR msg="mutliplexer panic" err="runtime error: invalid memory address or nil pointer dereference" stack="goroutine 54 [running]:\nruntime/debug.Stack()\n\t/opt/hostedtoolcache/go/1.22.5/x64/src/runtime/debug/stack.go:24 +0x5e\ngithub.com/sst/ion/cmd/sst/mosaic/multiplexer.(Multiplexer).Start.func2.1()\n\t/home/runner/work/ion/ion/cmd/sst/mosaic/multiplexer/multiplexer.go:99 +0x3f\npanic({0xb6d4920?, 0xc751a90?})\n\t/opt/hostedtoolcache/go/1.22.5/x64/src/runtime/panic.go:770 +0x132\ngithub.com/sst/ion/cmd/sst/mosaic/multiplexer.(Multiplexer).draw(0xc000d5a600)\n\t/home/runner/work/ion/ion/cmd/sst/mosaic/multiplexer/draw.go:63 +0xc88\ngithub.com/sst/ion/cmd/sst/mosaic/multiplexer.(Multiplexer).Start.func2(0xc000d5a600, {0xb9d0900, 0xc000d88280}, 0xc0010b1706)\n\t/home/runner/work/ion/ion/cmd/sst/mosaic/multiplexer/multiplexer.go:193 +0x8e7\ngithub.com/sst/ion/cmd/sst/mosaic/multiplexer.(Multiplexer).Start(0xc000d5a600)\n\t/home/runner/work/ion/ion/cmd/sst/mosaic/multiplexer/multiplexer.go:304 +0xc5\nmain.CmdMosaic.func8()\n\t/home/runner/work/ion/ion/cmd/sst/mosaic.go:184 +0x57\ngolang.org/x/sync/errgroup.(Group).Go.func1()\n\t/home/runner/go/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go:78 +0x56\ncreated by golang.org/x/sync/errgroup.(Group).Go in goroutine 1\n\t/home/runner/go/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go:75 +0x96\n"

Attaching the log file sst.log

jaapmvermeer commented 1 month ago

I wiped my Mac and started with a clean install and I no longer haver the issue. Thanks for your time and assistance.

OliverGeorge8 commented 1 month ago

i am having the same issue +1

OliverGeorge8 commented 1 month ago

I wiped my Mac and started with a clean install and I no longer haver the issue. Thanks for your time and assistance.

what did you wipe exactly ? can you provide some help writing about how you fixed it

jaapmvermeer commented 1 month ago

I think I had some kind of conflict with node versions, versions of node modules or other packages. I tried removing node, and all associated modules and libraries but after reinstalling I still had the issue so I decided to apply more drastic measure and using the Erase Assistant I reset my Mac to factory settings. This basically removes all content, settings, apps, user accounts and data. As I have all my files in the cloud, I only needed to reinstall some applications. This might not be the best approach for you but after a week of trying to find the underlying issue without success, this did the trick for me.

huangyuan3h commented 3 weeks ago

yes it happened when using yarn

john20xdoe commented 1 week ago

Possibly related? yarn might not be installing the dependencies inside .sst https://github.com/evanw/esbuild/issues/3060

thdxr commented 1 week ago

the user's package manager is not responsible for anything inside .sst - we try to insure .sst/platform/node_modules is populated correctly. can you check in there if that path-to-regexp package is missing?