LoginSignup
0
0

More than 5 years have passed since last update.

serveコマンドでnode.jsで書かれたサーバーを利用してプログラムを公開する際のエラー

Last updated at Posted at 2018-12-29

環境 :fallen_leaf:

仮想環境のOS:Ubuntu
node.js v7.10.1

エラー内容 :fallen_leaf:

serveコマンドを打つと、以下のエラーがでる。

/home/vagrant/.nvm/versions/node/v7.10.1/lib/node_modules/serve/node_modules/update-check/index.js:11
const writeFile = promisify(fs.writeFile);
                  ^

TypeError: promisify is not a function
    at Object.<anonymous> (/home/vagrant/.nvm/versions/node/v7.10.1/lib/node_modules/serve/node_modules/update-check/index.js:11:19)

エラーの原因:cry:

上記のディレクトリのindex.jsの11行目のpromisify()に問題がある的なエラーが出てるけど、そのindex.jsとにらめっこする必要はない

nodeのバージョンが古いことが、エラーの原因。

解決方法 :smile: :

なので、バージョンを8.x以上にする。これが解決方法。
nvmでnode.jsをインストールする際、バージョンを指定しなければ最新バージョンとなりますが、もし任意のバージョンを使いたかったり、v8.10.0がなかったらインストールしてください。

バージョン切り替え

nvm use v8.10.0

では、実際にserveコマンドやってみる

serve -s build -p 3000

これが表示されれば成功
サーバー立ち上げ.png

無事にwebサーバが起動した

感想 :smile: :

今回に限らず、バージョン7だとReactのプロジェクト作成からエラーが出るので、ノードのバージョンは新しくしましょう

0
0
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
0