Jay Rajput
Jay Rajput

Reputation: 121

How to run npm commands like create-react-app offline

I am working offline without any internet connectivity. I have node JS installed on my system. When I am trying to run the npm create-react-app command it gives me error. Is there any way for me to run npm commands and get react application running offline? Below is the error code I get:

npm ERR! code ENOTFOUND
npm ERR! errcode ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/create-react-app failed,
reason: getaddrinfo ENOTFOUND registry.npmjs.org

Upvotes: 4

Views: 3369

Answers (2)

Michael Stephen
Michael Stephen

Reputation: 81

I believe this is what you are looking for

https://npm.io/package/create-react-app-offline

It helps you create (download) a react project installer, which you can use to create any react JavaScript project offline.

Upvotes: 0

KawaLo
KawaLo

Reputation: 2284

and get react application running offline

npm start works offline already. Once you created your application, you should have no problem.

i am trying to run the npm create-react-app command [offline]

Npm is basically a package manager, which downloads dependencies for you, located under /node_modules at your project root.

create-react-app does two things :

  • Install specific dependencies for React : as a huge framework, React doesn't only require Node.js to run, but also multiple other packages (including React istelf).
  • Creating a template project with some presets.

If you are working offline and need to create multiple React projects that way, then you'll have no choice but to run the create-react-app command at least once while being online.

However, once you created your first React app, you can just leave the folder untouched : this will give you a fully functional offline copy for your React applications.

When you're back offline, just copy those files to the folder of the React application you want to create (make sure to copy everything, including the node_modules folder). You should then be able to run npm start offline, and build your application.

Upvotes: 2

Related Questions