pro-mern-stack icon indicating copy to clipboard operation
pro-mern-stack copied to clipboard

Page 28 - Transform - src doesn't exist

Open marcvc opened this issue 8 years ago • 13 comments

The following command results in an error:

C:\Marc\Web Development\MERN\chapter_02>node_modules.bin\babel src --presets react --out-dir static src doesn't exist

marcvc avatar Mar 09 '17 12:03 marcvc

Thanks, Marc.

You need to move the file App.jsx to a newly created directory called src under the project directory. This directory will hold all front-end code in the future. You have probably missed doing this (it's mentioned right at the beginning of the section).

If you want to continue using App.jsx in the root of the project folder, you could replace src with App.jsx and it will work.

vasansr avatar Mar 09 '17 13:03 vasansr

The app.jsx file is in the src folder. Does the src folder have to be in the static folder, or directly under the project root?

marcvc avatar Mar 09 '17 13:03 marcvc

Good point, Marc.

Please take a look at the GitHub repo source, it will be clear where each file / directory needs to be. For this section, you should be looking at: https://github.com/vasansr/pro-mern-stack/tree/02-transform

If you are in the main README page of the repo, click on the Full Source link next to the section name, in this case, "Transform" under Chapter 2.

The answer is, it has to be directly under the project root.

Also, please ensure all commands are being executed from the project root (ie, the project root as the current directory)

vasansr avatar Mar 09 '17 13:03 vasansr

Hi Vasan, I just checked, and the src folder was in the wrong place. I changed location and retried, but I am still getting the same error.

C:\Users\vanco>cd ../../

C:>cd marc/"web development"/mern/chapter_02

C:\Marc\Web Development\MERN\chapter_02>node_modules/.bin babel src --presets react --out-dir static 'node_modules' is not recognized as an internal or external command, operable program or batch file.

C:\Marc\Web Development\MERN\chapter_02>cd node_modules/.bin

C:\Marc\Web Development\MERN\chapter_02\node_modules.bin>babel src --presets react --out-dir static src doesn't exist

C:\Marc\Web Development\MERN\chapter_02\node_modules.bin>

marcvc avatar Mar 09 '17 13:03 marcvc

You're on Windows. All path separators (/) have to be back-slashes (\).

Try this:

C:>cd marc"web development"\mern\chapter_02

C:\Marc\Web Development\MERN\chapter_02>node_modules\.bin\babel src --presets react --out-dir static

In the command, you'll need to use \ and not / , since you're on Windows. In Windows, the / is a considered a separator between the command and its arguments. Thus, when you typed node_modules/.bin Windows thought that /.bin was an argument to the command node_modules. And, it replied that node_modules is not recognized as a command, which it is not.

vasansr avatar Mar 09 '17 13:03 vasansr

UNfortunately, still not working: C:\Marc\Web Development\MERN\chapter_02>node_modules****.bin babel src --presets react --out-dir static 'node_modules****.bin' is not recognized as an internal or external command, operable program or batch file.

marcvc avatar Mar 09 '17 13:03 marcvc

Sorry, I was trying to highlight using **. Please look at the previous comment again.

vasansr avatar Mar 09 '17 13:03 vasansr

With the backslash, it's still not recognized: C:\Marc\Web Development\MERN\chapter_02>node_modules.bin babel src --presets react --out-dir static 'node_modules.bin' is not recognized as an internal or external command, operable program or batch file.

marcvc avatar Mar 09 '17 14:03 marcvc

I think you're missing a slash (\) before .bin, or \ before babel. You need to know that you are running the command babel which resides in the directory node_modules\.bin. Using tab key to auto-complete is usually a good idea to what you want to do. Start with node_, press tab ... .bin, again tab ... you'll figure out what I mean.

vasansr avatar Mar 09 '17 14:03 vasansr

Yes! This command did the trick: C:\Marc\Web Development\MERN\chapter_02>node_modules.bin\babel src --presets react --out-dir static src\app.jsx -> static\app.js

Thanks a lot for your support, Vasan! I'm very new to this kind of web development, and I'm trying to catch on as quickly as I can.

marcvc avatar Mar 09 '17 15:03 marcvc

This feed was very helpful!!!! Thank you!!

Jelvibean avatar Nov 24 '17 19:11 Jelvibean

Hi I got this error when trying to run compile. Error: Couldn't find preset "es2015" relative to directory "src". Is there any idea what caused the problem? Many thanks.

capzman avatar Apr 08 '18 13:04 capzman

You're on Windows. All path separators (/) have to be back-slashes ().

Try this:

C:>cd marc"web development"\mern\chapter_02

C:\Marc\Web Development\MERN\chapter_02>node_modules.bin\babel src --presets react --out-dir static

In the command, you'll need to use \ and not / , since you're on Windows. In Windows, the / is a considered a separator between the command and its arguments. Thus, when you typed node_modules/.bin Windows thought that /.bin was an argument to the command node_modules. And, it replied that node_modules is not recognized as a command, which it is not.

works for me, Thank you

kelvin086 avatar Dec 24 '20 18:12 kelvin086