0
2

More than 5 years have passed since last update.

ConohaにReact環境を構築

Last updated at Posted at 2017-12-03

概要

・ConohaのVPS
・CentOS7.4で構築

手順

apacheインストール

yum -y install httpd
※7系ではデフォルトでfirewallが有効になっているため
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
systemctl restart firewalld
systemctl enable httpd
※適当に/var/www/html/index.htmlを作って、外からアクセスできることを確認

npmインストール

yum install yum-priorities
yum install epel-release.noarch
vim /etc/yum.repos.d/epel.repo
※yum updateしたときに消えないように
[epel]enabled=0に変更
yum install nodejs npm --enablerepo=epel

Reactプロジェクト作成

適当なワークディレクトリ移動
これを参考に「./node_modules/.bin/webpack」まで実行
https://qiita.com/akirakudo/items/77c3cd49e2bf39da79dd

エラー1:"Webpack has been initialised using a configuration object that does not match the API schema.~"
development.jsを修正
resolve: {
extensions: ['*', '.js']
},

エラー2:"Can't resolve 'babel'"
npm i -D babelを実行

エラー3:"The node API for babel has been moved to babel-core."
ここを参考に修正
https://github.com/babel/babel-loader/blob/master/README.md#the-node-api-for-babel-has-been-moved-to-babel-core

成功!
「./node_modules/.bin/webpack --display-error-details」でオプションをつけるとエラーの詳細が分かる。

あとは先ほどの参考ページでwebpack-dev-serverが起動できればひとまずOK

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2