LoginSignup
9
11

More than 5 years have passed since last update.

Windows上でNode.jsからSQLite3を使う方法

Last updated at Posted at 2015-09-11

WindowsでNode.js+SQLite3を使おうとして、インストールでつまずいたのでインストール方法をメモ。

簡単にインストールしたいのに...

Mac OS XやLinuxでは、以下のようにコマンド一発でインストールできるのに、Windows10でやったらエラーになりました。(node.jsがv4.0.0のとき)

npm install -g sqlite3

実行して出たエラーを見ると、どうやら、Pythonが必要な様子です。

Pythonのインストール

Pythonの公式サイト( https://www.python.org/downloads/ )よりPython2.7.xのインストーラーをダウンロードしてインストールします。そして、Python27にパスを通します。標準パスにインストールした場合は、管理者権限でコマンドプロンプトを起動して以下を実行します。

setx /m path "%path%;c:\Python27"

パスを通したら、Pythonが使えるので、これでOKです。

Visual Studioをインストール

これでOKだと思ったら、以下のようなエラーが出ます。

C:\Users\kujira\node_modules\sqlite3\build\binding.sln : error MSB3411: Visual
C++ コンポーネント "VCBuild.exe" を読み込めませんでした。コンポーネントがインス
トールされていない場合は、次のいずれかを行ってください。1)
 Microsoft Windows SDK for Windows Server 2008 と .NET Framework 3.5 をインスト
ールする。2
) Microsoft Visual Studio 2008 をインストールする。

そのため、以下より、Visual Studioあるいは、SDKをインストールする必要があります。

改めて npm を実行

無償のVisual Studioをインストールしている環境では、これでうまく行きました。

npm install -g sqlite3
9
11
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
9
11