sst / sst.dev

Repo for sst.dev
https://sst.dev
MIT License
3.68k stars 445 forks source link

Update create-a-new-reactjs-app.md #732

Closed jonasthiesen closed 10 months ago

jonasthiesen commented 10 months ago

Following the – otherwise incredibly amazing guide – there seems to be an issue on the following page: https://sst.dev/chapters/create-a-new-reactjs-app.html

When installing sst to packages/frontend, it fails with the following error when running pnpm run dev:

Error: No app is set

Trace: Error: No app is set
    at use (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22/node_modules/sst/constructs/FunctionalStack.js:44:15)
    at EmptyStack.ApiStack (file:///Users/jonasthiesen/code/sst-example/notes/.sst.config.1694033489155.mjs:35:21)
    at stack (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22_@types+react@18.2.21/node_modules/sst/constructs/FunctionalStack.js:20:35)
    at App.stack (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22_@types+react@18.2.21/node_modules/sst/constructs/App.js:490:16)
    at Object.stacks [as fn] (file:///Users/jonasthiesen/code/sst-example/notes/.sst.config.1694033489155.mjs:131:29)
    at Module.synth (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22_@types+react@18.2.21/node_modules/sst/stacks/synth.js:63:20)
    at async buildApp (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22_@types+react@18.2.21/node_modules/sst/cli/commands/bind.js:86:13)
    at async Object.handler (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22_@types+react@18.2.21/node_modules/sst/cli/commands/bind.js:51:9)
    at process.<anonymous> (file:///Users/jonasthiesen/code/sst-example/notes/node_modules/.pnpm/sst@2.24.22_@types+react@18.2.21/node_modules/sst/cli/sst.js:62:21)
    at process.emit (node:events:525:35)
    at process.emit (node:domain:489:12)
    at process._fatalException (node:internal/process/execution:149:25)
    at processPromiseRejections (node:internal/process/promises:288:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)

To me this sounds like it's getting a new "instance" of sst is created that doesn't have the app setup, which then let me to investigate the examples you have, e.g. this one: https://github.com/sst/sst/blob/0101c9f86c4c8c7ac7c05939d51b05c9050e12b4/examples/react-app/packages/frontend/package.json

On that one sst is not installed into packages/frontend itself.

I removed sst from packages/frontend and it seems to work perfectly now.

changeset-bot[bot] commented 10 months ago

⚠️ No Changeset found

Latest commit: caaff4f60053110b4d14275d3ac1d6bb45cb0ecf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

jayair commented 10 months ago

That's weird. We should install it there. Are you using pnpm? Can you share your version?

jonasthiesen commented 10 months ago

Yes, I'm using pnpm.

sst version 2.24.22 pnpm version 7.24.3

jonasthiesen commented 10 months ago

Oh wow. It seems to be a pnpm version thing. Just updated to latest (v8.7.4) and it seems to work now.

jayair commented 10 months ago

Yup, closing this for now.