简体   繁体   English

如何离线运行像 create-react-app 这样的 npm 命令

[英]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.我的系统上安装了节点 JS。 When i am trying to run the npm create-react-app command it gives me error.当我尝试运行 npm create-react-app命令时,它给了我错误。 Is there any way for me to run npm commands and get react application running offline.有什么方法可以让我运行 npm 命令并使 React 应用程序脱机运行。 Below is the error code i get:下面是我得到的错误代码:

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

and get react application running offline并让 React 应用程序离线运行

npm start works offline already. npm start已经可以离线工作了。 Once you created your application, you should have no problem.创建应用程序后,您应该没有问题。

i am trying to run the npm create-react-app command [offline]我正在尝试运行 npm create-react-app 命令 [离线]

Npm is basically a package manager, which downloads dependencies for you, located under /node_modules at your project root. Npm 基本上是一个包管理器,它为您下载依赖项,位于项目根目录的 /node_modules 下。

create-react-app does two things : create-react-app做了两件事:

  • 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).为 React 安装特定的依赖项:作为一个庞大的框架,React 不仅需要 Node.js 才能运行,还需要多个其他包(包括 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.如果您离线工作并且需要以这种方式创建多个 React 项目,那么您将别无选择,只能在在线时至少运行一次create-react-app命令。

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.然而,一旦你创建了你的第一个 React 应用程序,你就可以保持文件夹不变:这将为你的 React 应用程序提供一个功能齐全的离线副本。

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).当您重新离线时,只需将这些文件复制到您要创建的 React 应用程序的文件夹中(确保复制所有内容,包括 node_modules 文件夹)。 You should then be able to run npm start offline, and build your application.然后,您应该能够离线运行npm start并构建您的应用程序。

i believe this is what u are looking for我相信这就是你要找的

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

it helps you create (download) a react project installer, which u can use to create any react js project offline.它可以帮助您创建(下载)一个 react 项目安装程序,您可以使用它来离线创建任何 react js 项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在create-react-app创建的应用程序中使用jsx文件(不运行“npm run eject”)? - How to use jsx files in an app created by create-react-app (without run “npm run eject”)? npm run build使用create-react-app失败 - npm run build fails with create-react-app 什么是create-react-app中的“npm run build”? - What is “npm run build” in create-react-app? 如何离线查看一个简单的 create-react-app 组件? - How to view a simple create-react-app component offline? 使用 create-react-app 启动 npm 错误 - npm start error with create-react-app 使用 npm create-react-app 不起作用? - using npm create-react-app is not working? 如何在由React脚本生成的脚本中添加异步属性(在create-react-app模板上的npm run build阶段) - How to add async attribute to script generated by react scripts (at the npm run build stage on the create-react-app template) 如何在没有 create-react-app 的情况下像在 CRA 中一样配置代理? - How to configure a proxy like in CRA without create-react-app? 运行`npm run start`后,create-react-app如何重用现有的Browser选项卡? - How does create-react-app re-use an existing Browser tab after running `npm run start`? 我可以在没有 npm 启动和 npx create-react-app 的情况下使用 React 运行 index.html 吗? - Can I run index.html with React without npm start and npx create-react-app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM