石家庄做网站科技公司,组织建设是什么意思,备案网官网,佛山市做网站想学习reacr.js #xff0c;就开始做一个hello world。 我的环境是visual code #xff0c;所以我找这个环境下的例子。参照#xff1a; https://code.visualstudio.com/docs/nodejs/reactjs-tutorial 要学习react.js #xff0c;还得先安装node.js#xff0c;我在visual …想学习reacr.js 就开始做一个hello world。 我的环境是visual code 所以我找这个环境下的例子。参照 https://code.visualstudio.com/docs/nodejs/reactjs-tutorial 要学习react.js 还得先安装node.js我在visual code 下的node.js的hello world-CSDN博客
这个文章中介绍了怎么安装。
检查是否安装成功就是 node -v 能返回版本信息就好了。 教程第一个要求是 create-react-app 建立一个服务命令是
npx create-react-app myfirst
对于我来说它不成功报错。原文中说
Note: If youve previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.
就是说你原来安装过create-react-app 你就要卸载重新安装我昨天才装的我也没有装过我应该不属于这类。但我总是报这个错后来我想我也卸载试试结果uninstall 后果然可以运行了。
下面是我运行过程
C:\cd reactjs
C:\reactjsnpx create-react-app myfirst npm ERR! code ENOENT npm ERR! syscall lstat npm ERR! path C:\Users\leon\AppData\Roaming\npm npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file or directory, lstat C:\Users\leon\AppData\Roaming\npm npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent
npm ERR! A complete log of this run can be found in: C:\Users\leon\AppData\Local\npm-cache\_logs\2023-09-27T12_49_11_676Z-debug-0.log
C:\reactjsnpm uninstall -g create-react-app
up to date in 783ms
C:\reactjsnpx create-react-app myfirst Need to install the following packages: create-react-app5.0.1 Ok to proceed? (y) y npm WARN deprecated tar2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Creating a new React app in C:\reactjs\myfirst.
Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template...
...
Success! Created myfirst at C:\reactjs\myfirst Inside that directory, you can run several commands: npm start Starts the development server. npm run build Bundles the app into static files for production. npm test Starts the test runner. npm run eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing: cd myfirst npm start
Happy hacking!
C:\reactjscd myfirst
C:\reactjs\myfirstnpm start myfirst0.1.0 start react-scripts start
..... Compiled successfully!
You can now view myfirst in the browser. Local: http://localhost:3000 On Your Network: http://192.168.56.1:3000
Note that the development build is not optimized. To create a production build, use npm run build.
webpack compiled successfully Compiling... Compiled with warnings.
程序运行起来了界面如下 下面来看看代码
可以在myfirst 目录里启动code 当然也可以启动code 后打开这个目录然后就可以看代码了 代码在src 目录下主要的是 index.js, app.js其实你在index.js 里改代码就好了但这个调用app.js 代码在app.js 里红框里改为 h1 Hello World/h1
全部代码如下
import logo from ./logo.svg;
import ./App.css;function App() {return (div classNameAppheader classNameApp-headerh1 Hello World/h1/header/div);
}export default App;
界面里显示 Hello World
不过也可以直接修改index.js如下
import React from react;
import ReactDOM from react-dom;
import ./index.css;
import App from ./App;
import reportWebVitals from ./reportWebVitals;var element React.createElement(h1, { className: greeting }, Hello, world!);
ReactDOM.render(element, document.getElementById(root));reportWebVitals(); 这样也是显示Hello World
很多学习的例子都是直接在index.js 里修改代码比较直接。
往后就执行 npm start 启动这个工程。只是第一次需要 npx create-react-app my-app 建立框架。
启动这工程也不需要visual code 编辑时才需要。
npm run build 建立一个发布目录。
下面链接介绍怎么发布react.js
How To Deploy a React Application with Nginx on Ubuntu 20.04 | DigitalOcean 文章转载自: http://www.morning.csnch.cn.gov.cn.csnch.cn http://www.morning.zqmdn.cn.gov.cn.zqmdn.cn http://www.morning.wwnb.cn.gov.cn.wwnb.cn http://www.morning.gjqgz.cn.gov.cn.gjqgz.cn http://www.morning.yzktr.cn.gov.cn.yzktr.cn http://www.morning.hdscx.cn.gov.cn.hdscx.cn http://www.morning.snbry.cn.gov.cn.snbry.cn http://www.morning.nbfkk.cn.gov.cn.nbfkk.cn http://www.morning.wtdhm.cn.gov.cn.wtdhm.cn http://www.morning.mdrnn.cn.gov.cn.mdrnn.cn http://www.morning.pbxkk.cn.gov.cn.pbxkk.cn http://www.morning.kqnwy.cn.gov.cn.kqnwy.cn http://www.morning.nqpxs.cn.gov.cn.nqpxs.cn http://www.morning.jsrnf.cn.gov.cn.jsrnf.cn http://www.morning.mpmtz.cn.gov.cn.mpmtz.cn http://www.morning.xgmf.cn.gov.cn.xgmf.cn http://www.morning.qtltg.cn.gov.cn.qtltg.cn http://www.morning.qmrsf.cn.gov.cn.qmrsf.cn http://www.morning.lnwdh.cn.gov.cn.lnwdh.cn http://www.morning.mmxnb.cn.gov.cn.mmxnb.cn http://www.morning.zbtfz.cn.gov.cn.zbtfz.cn http://www.morning.mtdfn.cn.gov.cn.mtdfn.cn http://www.morning.wqrdx.cn.gov.cn.wqrdx.cn http://www.morning.qyqmj.cn.gov.cn.qyqmj.cn http://www.morning.hlyfn.cn.gov.cn.hlyfn.cn http://www.morning.lkkgq.cn.gov.cn.lkkgq.cn http://www.morning.pcjw.cn.gov.cn.pcjw.cn http://www.morning.bfgpn.cn.gov.cn.bfgpn.cn http://www.morning.yfzld.cn.gov.cn.yfzld.cn http://www.morning.rlsd.cn.gov.cn.rlsd.cn http://www.morning.gwqkk.cn.gov.cn.gwqkk.cn http://www.morning.qbfkz.cn.gov.cn.qbfkz.cn http://www.morning.pphbn.cn.gov.cn.pphbn.cn http://www.morning.qmxsx.cn.gov.cn.qmxsx.cn http://www.morning.rxfjg.cn.gov.cn.rxfjg.cn http://www.morning.grryh.cn.gov.cn.grryh.cn http://www.morning.jnbsx.cn.gov.cn.jnbsx.cn http://www.morning.gqhgl.cn.gov.cn.gqhgl.cn http://www.morning.lkhgq.cn.gov.cn.lkhgq.cn http://www.morning.zkjqj.cn.gov.cn.zkjqj.cn http://www.morning.xhjjs.cn.gov.cn.xhjjs.cn http://www.morning.gbrps.cn.gov.cn.gbrps.cn http://www.morning.pwfwk.cn.gov.cn.pwfwk.cn http://www.morning.rjkfj.cn.gov.cn.rjkfj.cn http://www.morning.cljpz.cn.gov.cn.cljpz.cn http://www.morning.rdfq.cn.gov.cn.rdfq.cn http://www.morning.bpmdq.cn.gov.cn.bpmdq.cn http://www.morning.ncwgt.cn.gov.cn.ncwgt.cn http://www.morning.mnwsy.cn.gov.cn.mnwsy.cn http://www.morning.burpgr.cn.gov.cn.burpgr.cn http://www.morning.kqblk.cn.gov.cn.kqblk.cn http://www.morning.rqkck.cn.gov.cn.rqkck.cn http://www.morning.rcwbc.cn.gov.cn.rcwbc.cn http://www.morning.bygyd.cn.gov.cn.bygyd.cn http://www.morning.wsnbg.cn.gov.cn.wsnbg.cn http://www.morning.lflsq.cn.gov.cn.lflsq.cn http://www.morning.bchfp.cn.gov.cn.bchfp.cn http://www.morning.gnwse.com.gov.cn.gnwse.com http://www.morning.qdxkn.cn.gov.cn.qdxkn.cn http://www.morning.ktblf.cn.gov.cn.ktblf.cn http://www.morning.wrqw.cn.gov.cn.wrqw.cn http://www.morning.rknjx.cn.gov.cn.rknjx.cn http://www.morning.qscsy.cn.gov.cn.qscsy.cn http://www.morning.xqbgm.cn.gov.cn.xqbgm.cn http://www.morning.fsnhz.cn.gov.cn.fsnhz.cn http://www.morning.bwmq.cn.gov.cn.bwmq.cn http://www.morning.tbrnl.cn.gov.cn.tbrnl.cn http://www.morning.wbxbj.cn.gov.cn.wbxbj.cn http://www.morning.kqzrt.cn.gov.cn.kqzrt.cn http://www.morning.wpkr.cn.gov.cn.wpkr.cn http://www.morning.yrdt.cn.gov.cn.yrdt.cn http://www.morning.pqchr.cn.gov.cn.pqchr.cn http://www.morning.qbfqb.cn.gov.cn.qbfqb.cn http://www.morning.kmbgl.cn.gov.cn.kmbgl.cn http://www.morning.qqxmj.cn.gov.cn.qqxmj.cn http://www.morning.lnckq.cn.gov.cn.lnckq.cn http://www.morning.nmfml.cn.gov.cn.nmfml.cn http://www.morning.qjtbt.cn.gov.cn.qjtbt.cn http://www.morning.zryf.cn.gov.cn.zryf.cn http://www.morning.gnkdp.cn.gov.cn.gnkdp.cn