0
1

More than 3 years have passed since last update.

Visual Studioでnpmを使う方法

Posted at

マイクロソフトの公式ドキュメントを参考
参考URL

Node.jsプロジェクトの場合

1.「新しいnpmパッケージのインストール」をクリック

image.png

2.パッケージを検索し、「パッケージのインストール」をクリック

画像はjQueryをインストールしている。
image.png

.Net Coreプロジェクトの場合

1.拡張機能タブ > 拡張機能の管理 > 「Package Installer」をインストールする

image.png

2.「Quick Install Package...」をクリック

image.png

結果
node_modulesフォルダができて、中にjQueryができる。

image.png

3.「wwwroot」フォルダに追加するように変えたい場合は...

  • NuGetパッケージより、「BuildBundlerMinifier」をインストールする

image.png

  • 「bundleconfig.json」ファイルを新規作成する。

以下のように中身を書き換える

[
  {
    "outputFileName": "wwwroot/lib/jquery.js",
    "inputFiles": [
      "node_modules/jQuery/tmp/jquery.js"
    ],
    "minify": {
      "enabled": true,
      "renameLocals": true
    }
  }
]

これで、node_modules内のjuery.jsがwwwrootに追加される。

ちなみに

package.jsonを直接作って、インストールするパッケージを入力して保存すれば、
勝手にインストールしてくれる

こんな感じ
{
  "name": "myproject",
  "version": "1.0.0",
  "devDependencies": {
    "jQuery": "^1.7.4",
    "gulp": "4.0.2",
    "@types/jquery": "3.3.33"
  }
}
0
1
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
1