Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React project failing to compile after changing a file name from .js to .jsx

I've run into a bit of a snag.

I realized that a partner on my project set up a file as .js instead of .jsx. I switched the filetype to match the rest of the files in the project and now I'm getting hit with this error.

index.js:1 ./src/Components/SignUp/SignUp.js Error: ENOENT: no such file or directory, open '~/src/Components/SignUp/SignUp.js'

I subbed out some of the pathing for the '~'.

I've searched through my project for all instances of SignUp and can't find anything that would seem to lock it into looking for a .js file. Does anyone have any suggestions?

like image 569
Kadus Avatar asked Dec 12 '19 12:12

Kadus


People also ask

Is there a difference between adding JSX inside .JS and .JSX files?

Conclusion. JS is simply a scripting language, adding functionality into your website. JSX is an addition to the JavaScript syntax which is a mixture of both HTML and JavaScript. Both JS and JSX are interchangeable but JSX makes the code easier to understand for users.

How do I rename a file in React?

Right-click a folder or a component file in the file explorer and select Rename React Component towards the bottom of the context menu. Run ( Rename React Component ) in the command palette. This will rename the currently open React component.

What is the .JSX extension?

What is JSX? JSX stands for JavaScript XML. JSX allows us to write HTML in React. JSX makes it easier to write and add HTML in React.

How React convert JSX to JS?

So to convert it to browser understandable JavaScript code, we use a tool like Babel which is a JavaScript compiler/transpiler. You can set up your own babel configuration using Webpack as I show in this article. Or you can use create-react-app which internally uses Babel for the JSX to JavaScript conversion.


1 Answers

The issue resolved with the magic of turning it on and off again. Although you can add files without restarting the server, the editing of a file name (or at least file extension) requires a restart of the server.

like image 198
Kadus Avatar answered Sep 30 '22 14:09

Kadus