<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>React | Men of Letters（メン・オブ・レターズ） &#8211; 論理的思考/業務改善/プログラミング</title>
	<atom:link href="https://laboratory.kazuuu.net/category/react/feed/" rel="self" type="application/rss+xml" />
	<link>https://laboratory.kazuuu.net</link>
	<description></description>
	<lastBuildDate>Mon, 04 Jul 2022 05:54:33 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://laboratory.kazuuu.net/wp-content/uploads/2021/02/cropped-L-32x32.png</url>
	<title>React | Men of Letters（メン・オブ・レターズ） &#8211; 論理的思考/業務改善/プログラミング</title>
	<link>https://laboratory.kazuuu.net</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/>
<atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/>
<atom:link rel="hub" href="https://websubhub.com/hub"/>
<atom:link rel="self" href="https://laboratory.kazuuu.net/category/react/feed/"/>
	<item>
		<title>ReactをインストールしReactアプリを作成する（Windows10）</title>
		<link>https://laboratory.kazuuu.net/install-react-and-create-a-react-app-windows10/</link>
					<comments>https://laboratory.kazuuu.net/install-react-and-create-a-react-app-windows10/#respond</comments>
		
		<dc:creator><![CDATA[小林]]></dc:creator>
		<pubDate>Mon, 04 Jul 2022 05:54:33 +0000</pubDate>
				<category><![CDATA[React]]></category>
		<guid isPermaLink="false">https://laboratory.kazuuu.net/?p=12977</guid>

					<description><![CDATA[ReactをインストールしReactアプリを作成してみます（Windows10） 目次 ■PC環境■ディレクトリを作成する■プロジェクトディレクトリに移動する■package.jsonファイルを作成する■Windows1 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>ReactをインストールしReactアプリを作成してみます（Windows10）</p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">■PC環境</a></li><li><a href="#toc2" tabindex="0">■ディレクトリを作成する</a></li><li><a href="#toc3" tabindex="0">■プロジェクトディレクトリに移動する</a></li><li><a href="#toc4" tabindex="0">■package.jsonファイルを作成する</a></li><li><a href="#toc5" tabindex="0">■Windows10にreactをインストールする</a></li><li><a href="#toc6" tabindex="0">■Create-React-App Toolのインストール</a></li><li><a href="#toc7" tabindex="0">■新しいReactプロジェクトを作成する</a></li><li><a href="#toc8" tabindex="0">■アプリケーションの実行をする</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">■PC環境</span></h2>
<p>&gt;Windows 10</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/2022-06-07-1.png"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-12528" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/2022-06-07-1-300x282.png" alt="" width="300" height="282" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/2022-06-07-1-300x282.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/2022-06-07-1-1024x963.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/2022-06-07-1-768x723.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/2022-06-07-1.png 1250w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>・node &#8211;version v16.14.0</p>
<p>・npm &#8211;version 8.3.1</p>
<p>※ReactをインストールしReactアプリを作成するために、<span style="background-color: #ff99cc;">Node.jsをインストールする必要があります。</span></p>
<h2><span id="toc2">■ディレクトリを作成する</span></h2>
<p>Reactアプリを作成するために、まずはディレクトリを作成します。</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_9-1.png"><img decoding="async" class="alignnone size-medium wp-image-12979" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_9-1-300x181.png" alt="" width="300" height="181" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_9-1-300x181.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_9-1-1024x618.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_9-1-768x463.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_9-1.png 1250w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>今回は「C:\Users\user_（フォルダパス）」内に「react-app-test」という空のディレクトリを作成します。これが、Reactアプリを作成するためのプロジェクトディレクトリとなります。</p>
<h2><span id="toc3">■プロジェクトディレクトリに移動する</span></h2>
<p>プロジェクトディレクトリを作成後、Windows10のコマンドプロンプトを起動します。</p>
<pre>&gt;cd react-app-test</pre>
<p>起動後、上記のコマンドを入力し、Enterキーを押します。「cd」コマンドで「react-app-test」プロジェクトディレクトリに移動します。</p>
<h2><span id="toc4">■package.jsonファイルを作成する</span></h2>
<p>移動後、プロジェクトで使用しているすべての種類の依存関係をJSON形式で記録するために、package.jsonファイルを作成します。</p>
<pre>&gt;npm init</pre>
<p>作成のために、コマンドプロンプト上で上記のコマンドを入力し、Enterキーを押します。</p>
<pre>This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install ` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (react-app-test)</pre>
<p>Enterキーを押すと、上記のメッセージが出力されます。「package name: (react-app-test)」と表示された後にEnterキーを押します。</p>
<pre>version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to C:\Users\user_\react-app-test\package.json:

{
  "name": "react-app-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes)</pre>
<p>Enterキーを押すと、「description:」や「entry point: (index.js)」といった出力がされますが、Enterキーを押していきます。押していくと「Is this OK? (yes)」と出力されます。この出力でEnterキーを押します。押すと、package.jsonファイルが作成されます。</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-142243-1.png"><img decoding="async" class="alignnone size-medium wp-image-12980" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-142243-1-300x153.png" alt="" width="300" height="153" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-142243-1-300x153.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-142243-1-1024x522.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-142243-1-768x391.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-142243-1.png 1250w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_5-1-1.png"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-12981" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_5-1-1-300x160.png" alt="" width="300" height="160" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_5-1-1-300x160.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_5-1-1-1024x547.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_5-1-1-768x410.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04_5-1-1.png 1250w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>作成後、「react-app-test」ディレクトリ内を確認すると、package.jsonファイルが作成されていることが確認できました。</p>
<h2><span id="toc5">■Windows10にreactをインストールする</span></h2>
<p>確認後、Windows10にreactをインストールします。</p>
<pre>react-app-test &gt; npm install --save react
react-app-test &gt; npm install --save react-dom</pre>
<p>インストールするために、コマンドプロンプト上で、上記のコマンドを入力し、Enterキーを押します。</p>
<pre>added 3 packages, and audited 4 packages in 2s

found 0 vulnerabilities</pre>
<pre>added 2 packages, and audited 6 packages in 2s

found 0 vulnerabilities</pre>
<p>「react」と「react-dom」をインストールすると、上記のように出力されます。これでインストールは完了となります。</p>
<h2><span id="toc6">■Create-React-App Toolのインストール</span></h2>
<p>完了後、React.jsをインストールするために、Create-React-App Toolのインストールを行います。このツールを用いることで、簡単にReactアプリケーションを作成することができます。</p>
<pre>react-app-test &gt; npm install -g create-react-app</pre>
<p>インストールするために、コマンドプロンプト上で、上記のコマンドを入力し、Enterキーを押します。</p>
<pre>npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

added 67 packages, and audited 68 packages in 38s

4 packages are looking for funding
  run `npm fund` for details

2 high severity vulnerabilities

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.</pre>
<p>Enterキーを押すと、インストールが開始され、上記のメッセージが出力されます。これでインストールは完了です。「WARN（警告）」が出力されていますが、エラーではないので、今回は一旦無視します。</p>
<h2><span id="toc7">■新しいReactプロジェクトを作成する</span></h2>
<p>インストール完了後、Create-React-App Toolを使用しreactアプリケーションを作成できます。</p>
<pre>react-app-test &gt; create-react-app project-name</pre>
<p>作成するために、コマンドプロンプト上で、上記のコマンドを入力し、Enterキーを押します。今回は「create-react-app」コマンドを用いて、「project-name」から名前を変更し、新しく作成するReactプロジェクトフォルダである「react-app-test」を指定します。</p>
<pre>Success! Created react-app-test at C:\Users\user_\react-app-test\react-app-test
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 react-app-test
  npm start

Happy hacking!</pre>
<p>Enterキーを押すと、上記のメッセージが出力されます。これでプロジェクトディレクトリ「react-app-test」内に「react-app-test」フォルダが作成されました。</p>
<h2><span id="toc8">■アプリケーションの実行をする</span></h2>
<p>作成後、確認と検証のために、アプリケーションの実行を行います。</p>
<pre>react-app-test &gt; cd react-app-test</pre>
<p>まず、コマンドプロンプト上で上記のコマンドを入力し、Enterキーを押します。cdコマンドでプロジェクトディレクトリ「react-app-test」内の「react-app-test」フォルダに移動します。</p>
<pre>react-app-test\react-app-test&gt; npm start</pre>
<p>移動後、さらに上記のコマンドを入力し、Enterキーを押します。「npm start」コマンドでプロジェクトを開始します。</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-145002-1.png"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-12982" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-145002-1-300x165.png" alt="" width="300" height="165" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-145002-1-300x165.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-145002-1-1024x562.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-145002-1-768x421.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/07/スクリーンショット-2022-07-04-145002-1.png 1249w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>開始すると、Webブラウザが起動し、「http://localhost:3000/」にアクセスし、「React App」というタイトルのReactアプリケーションが実行されることを確認できました。</p>
<pre>&gt; react-app-test@0.1.0 start
&gt; react-scripts start

(node:15724) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:15724) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
Starting the development server...
Compiled successfully!

You can now view react-app-test in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://172.23.80.1:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

webpack compiled successfully
</pre>
<p>なお、「Windows PowerShell」内には上記のようなメッセージが出力されることも確認できました。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://laboratory.kazuuu.net/install-react-and-create-a-react-app-windows10/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
