I downloaded a project from codesandbox. Its folder structure and index file looks as following:
index.js file:
const { StrictMode } = require("react");
const ReactDOM=require("react-dom") ;
const App = require("./App")
const rootElement = document.getElementById("root");
ReactDOM.render(
<StrictMode>
<App />
</StrictMode>,
rootElement
);
after running npm intall, package.json looks like this:
{
"name": "quill-forms-example",
"version": "1.0.0",
"description": "How to create typeform clone easily with React",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"@quillforms/react-renderer-utils": "1.0.25",
"@quillforms/renderer-core": "1.5.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-scripts": "5.0.1"
},
"devDependencies": {
"@babel/runtime": "7.13.8",
"typescript": "4.1.3"
},
"scripts": {
"build": "react-scripts build"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
I tried running with node index.js inside src folder in VSC. but I will get the following error in line 8 of the index.js as following:
C:UsersShafighDownloadsquill-forms-example-forkedsrcindex.js:8
<StrictMode>
^
SyntaxError: Unexpected token '<'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
any hint, what changes should i make to the code?
2
Answers
First run
npm install
in the terminal of root folder (not src folder) which will take a while since it will install all the packages in package.json.Then run
npm run dev
which will start it in a browser most possibly in localhost:3000. Hope that solves your problem.Remove
StrictMode