LoginSignup
0
0

More than 3 years have passed since last update.

Node.jsをWindows10にインストールして詰まったこと

Posted at

背景

AWSでNode.jsを触ってみようと思い立ち、まずはAWSの開発者ガイドに従って開発環境を構築してみた。

参考にしたURL

https://docs.aws.amazon.com/ja_jp/elasticbeanstalk/latest/dg/nodejs-devenv.html
https://qiita.com/taiponrock/items/9001ae194571feb63a5e

詰まったこと

 Node.js&npmをインストールしたので、動作確認(npm start)するとエラーが出てしまった。

node:internal/modules/cjs/loader:928
  throw err;

Error: Cannot find module 'http-errors'
Require stack:
- hoge\app.js
- hoge\bin\www

エラーの出た環境

 OS:Windows10 Pro(バージョン2004 OSビルド19041.746)
 node.jsインストーラ:node-v15.6.0-x64.msi

調べてみた

どうも、Node.jsのインストールは一発目は失敗することが多い模様。(Windowsだから?)

参考にしたURL

https://github.com/nodejs/help/issues/2644
https://qiita.com/Sakuya_wd/questions/9d2af3b47047aad652fc

確認してみた

同じようなトラブルに見舞われているところでは、node_modulesフォルダを消して再インストールするという解決策が提示されていた。
まず、インストールフォルダを確認したところ、自分の環境ではnode_modulesフォルダが存在していなかった。

やってみた

node_modulesフォルダがもうないんだから、そのまま再インストールをやってみる。

npm install

警告は出るけど、エラーは出てないっぽいから、改めて動作確認をした。

npm start

> node-express@0.0.0 start
> node ./bin/www

GET / 200 1701.982 ms - 170
GET /stylesheets/style.css 200 9.003 ms - 111
GET /favicon.ico 404 33.771 ms - 1132

今度はちゃんとサンプルコードが動いた。
インストーラーからだとモジュール類がちゃんと入らないってことなのかな?

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