8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Node】npmstartすると、Something is already running on port 8080. Probably:と言われてしまう件【React】

Last updated at Posted at 2021-04-09

症状

cloud9でnpmstartを一度実行した状態で誤ってターミナルを閉じてしまい、再度開きなおしてnpmstartをすると下記のような表示されるようになってしまいました。 翻訳すると、「何かがすでにポート8080で実行されています。おそらく:(中略)代わりに、別のポートでアプリを実行しますか?」

yを押すと、npmstartは動作するようにはなりますが、実行するたびに表示されるのはめんどくさいので解消します。

$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

? Something is already running on port 8080. Probably:
  /home/ubuntu/.nvm/versions/node/v12.16.1/bin/node /home/ubuntu/environment/プロジェクト名/frontend/node_modules/react-scripts/scripts/start.js (pid 15133)
  in /home/ubuntu/environment/プロジェクト名/frontend

Would you like to run the app on another port instead? › (Y/n)

解決策

killコマンドでプロセスを停止させることで、同様のメッセージは表示されないようになりました。
# ポート番号は任意のものに変えて使用してください
npx kill-port 8080

参考

Node.js Port 3000 already in use but it actually isn't? https://stackoverflow.com/questions/39322089/node-js-port-3000-already-in-use-but-it-actually-isnt
8
3
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
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?