LoginSignup
16
10

More than 5 years have passed since last update.

npmのモジュールを依存しているモジュールごとpack

Last updated at Posted at 2015-03-05

社内環境などのproxy環境下でregistryからのnpm installが403で一切できなかったのでなんとか依存モジュールを含めたpackageを生成できないか試行錯誤してみた。

packageの生成

目的のモジュールをnpm installする

※ここではネットワークに接続する必要あり=家でやる

追記>>>
これができないとなると全ての依存モジュールでpackを繰り返すことになる。
<<<

モジュールのpackage.jsonの修正

例)gulp.js

package.json
  "dependencies": {
    "archy": "^1.0.0",
    "chalk": "^0.5.0",
    "deprecated": "^0.0.1",
    "gulp-util": "^3.0.0",
    "interpret": "^0.3.2",
    "liftoff": "^2.0.1",
    "minimist": "^1.1.0",
    "orchestrator": "^0.3.0",
    "pretty-hrtime": "^0.2.0",
    "semver": "^4.1.0",
    "tildify": "^1.0.0",
    "v8flags": "^2.0.2",
    "vinyl-fs": "^0.3.0"
  },

//下記を追記

  "bundledDependencies": [
    "archy",
    "chalk",
    "deprecated",
    "gulp-util",
    "interpret",
    "liftoff",
    "minimist",
    "orchestrator",
    "pretty-hrtime",
    "semver",
    "tildify",
    "v8flags",
    "vinyl-fs"
  ],

npm pack

terminal cmd.exeなりでモジュールのディレクトリ(package.jsonがあるディレクトリ)に移動。
(gulp.jsなら node_modules/gulp)

npm pack

これでpackage.tgzができる。
展開すればnode_modulesが含まれていることがわかる。

proxy環境下でインストールする

npm install ./package.tgz

これで無事にインストールされる予定。明日試す

追記:インストールできました。

16
10
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
16
10