vasansr / pro-mern-stack

Code Listing for the book Pro MERN Stack
http://www.apress.com/in/book/9781484226520
343 stars 159 forks source link

Page 28 - Transform - src doesn't exist #2

Open marcvc opened 7 years ago

marcvc commented 7 years ago

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

vasansr commented 7 years ago

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.

marcvc commented 7 years ago

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?

vasansr commented 7 years ago

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)

marcvc commented 7 years ago

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>

vasansr commented 7 years ago

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.

marcvc commented 7 years ago

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.

vasansr commented 7 years ago

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

marcvc commented 7 years ago

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.

vasansr commented 7 years ago

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 nodemodules\.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.

marcvc commented 7 years ago

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.

Jelvibean commented 6 years ago

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

capzman commented 6 years ago

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.

kelvin086 commented 3 years ago

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