2

I know that NodeJS is important when using npm to download modules but does react depends from it? For example i have a react app created from create-react-app and i have this part:

import ReactDOM from 'react-dom';
import './index.css';

Is nodeJs used to configure the paths in the files or is it just the babel compiler that does that?

If yes, is babel configured to look in the node_modules files like NodeJs does?

1 Answer 1

1

Babel is unaware of modules. It is the responsibility of a bundler (Webpack in create-react-app) to handle module imports.

Webpack resolver works similarly to Node resolver regarding node_modules, this can be configured.

Sign up to request clarification or add additional context in comments.

10 Comments

So nodeJs is only useful for npm modules?
I'm not sure what you mean. It's altogether useful. Webpack is Node tool. You wouldn't be able to use tools written in JS from command line without Node. React doesn't depend on Node. Build tools do.
I mean tha Nodejs is useful only from the command line like using npm downloading packages
Yes, it's useful for command line but command line is used for many things, like building React app. When you start an app with npm run start, it runs Node. You may take a look on what exactly CRA does by ejecting a project with npm run eject or checking CRA internals, github.com/facebook/create-react-app/tree/master/packages/… . It's basically Webpack+Babel+Jest template, all of these tools use Node.
" It's basically Webpack+Babel+Jest template, all of these tools use Node" you mean that Webpack+Babel+Jest HAVE tools that depend on Node and not Webpack+Babel+Jest themselves depend on Node right? And one last thing: When downloading from npm packages like redux, npm saves them in C:\Users\user\AppData\Local\Microsoft\TypeScript\. How webpack knows this location?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.