React syntaxError

hello there,
Am just starting to learn Reactjs, below is my html and js setup how ever i keep getting syntaxerror

<!DOCTYPE html>
<html lang="en">

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <div id="root">

  <script src="" crossorigin></script>
  <script src="" crossorigin></script>
  <script src=""></script>

  <!-- Load our React component. -->
  <script src="app.js"></script>

const test = <h1>This is testing</h1>;

ReactDOM.render(test, document.getElementById('root'));

are you sure you don’t need to compile your js first?

Ooookayy… lemme try adding type="text/babel" attr to the js script tag

I would suggest using Vite or create-react-app, the scripts are not meant for anything serious and they really offer no benefits.

  1. Install Node.js

  2. Open a terminal and run npm create vite@latest my-app -- --template react

Thanks a lot, that helped

Hello there,
how do i set the npm even for all subfolders in a directory

I don’t understand the question.

Can you explain what you are trying to do?

oh sorry,
i meat to say like setting up a dev environment for a directory that has nested folders inside it.

There is nothing preventing you from nesting folders inside the same project as long as you keep the package.json file and node_modules folder in the root and use the correct paths for the imports.

Still not sure what it is you are trying to achieve?

If you are talking about multiple projects with their own dependencies living inside a common root folder you can use something like Workspaces (all the latest package managers should have this feature now) or you can look at Monorepos.

I get the feeling it would be overkill and isn’t what you are actually looking for.

yeah, multiple projects with their own dependencies.
thanks by the way vite is really fast even on this 4GB RAM of mine

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.