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

Cannot build project example #1

Open
luciob opened this issue Jun 3, 2024 · 0 comments
Open

Cannot build project example #1

luciob opened this issue Jun 3, 2024 · 0 comments

Comments

@luciob
Copy link

luciob commented Jun 3, 2024

Hello, I'm trying to run the x0 project on my laptop. I'm temporary skipping the OpenAI connection and the code generation step (will introduce that later on). The goal is to have a response from the backend with an hardcoded component example written in TS using your component library.

In dev mode everything works fine: code is transpiled and returned to FE.
In build mode instead, code gets built correctly, but I receive an error if I try to serve it.

These are the changes I made to your project, starting from branch 5-fix-errors-iteratively-step.

Inside backend folder I've added the following scripts to package.json (removed config.env as not needed atm):

    "build": "tsc",
    "serve": "node dist/src/server.js",
    "serve:dev": "tsx src/server.ts",

I've changed the pipeline method to run only the following code:

  const path = saveGeneratedFile(SOURCE_CODE);
  return {
    code: SOURCE_CODE,
    path,
  };

Where SOURCE_CODE is the hardcoded component.

Finally I've added a new backend script and renamed backend:dev script into the global package.json file:

  "scripts": {
    "backend": "npm run serve --prefix ./backend",
    "backend:dev": "npm run serve:dev --prefix ./backend",
    "frontend": "npm run dev --prefix ./frontend"
  },

If I run npm backend I get the following error, returned as soon as the command starts:

/~/codemotion-x0/backend/node_modules/@mui/material/OutlinedInput/outlinedInputClasses.js:1
import _extends from "@babel/runtime/helpers/esm/extends";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:76:18)
    at wrapSafe (node:internal/modules/cjs/loader:1283:20)
    at Module._compile (node:internal/modules/cjs/loader:1328:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/~/codemotion-x0/backend/node_modules/@xtreamsrl/react-ui-kit/src/TextInput/TextInput.styled.js:9:48)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)

The same behaviour happens if I install npm i --save-dev ts-node and use it in place of tsx when running in dev mode.
I think I'm missing a piece of how it is supposed to work.
Can you please help me out?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant