LoginSignup
4
1

More than 5 years have passed since last update.

npm shrinkwrap で失敗したときの対処法

Last updated at Posted at 2017-03-10

npm shrinkwrapを使うと依存モジュールのバージョンまで固定した状態でインストールする事ができます。

ですが、実行したら、エラーが出てしまいました。
復帰方法をメモします。

失敗した場合

私の場合、下記のように上手く行かない場合がありました。

$ npm shrinkwrap  
npm WARN unmet dependency ~/path/to/node_modules/nock/node_modules/changelog requires chalk@'^0.5.1' but will load
npm WARN unmet dependency ~/path/to/node_modules/chalk,
npm WARN unmet dependency which is version 1.1.3
npm WARN unmet dependency ~/path/to/node_modules/nock/node_modules/changelog requires semver@'^4.0.3' but will load
npm WARN unmet dependency ~/path/to/node_modules/semver,
npm WARN unmet dependency which is version 5.3.0
npm ERR! Darwin 15.6.0
npm ERR! argv "~/.nodebrew/node/v4.7.2/bin/node" "~/.nodebrew/current/bin/npm" "shrinkwrap"
npm ERR! node v4.7.2
npm ERR! npm  v2.15.11

npm ERR! Problems were encountered
npm ERR! Please correct and try again.
npm ERR! invalid: chalk@1.1.3 ~/path/to/node_modules/chalk
npm ERR! invalid: semver@5.3.0 ~/path/to/node_modules/semver
npm ERR! extraneous: changelog@1.0.7 ~/path/to/node_modules/nock/node_modules/changelog
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     ~/path/to/npm-debug.log

解決方法

npmのキャッシュをクリアしたら上手く行きました。
npm cache clearコマンドでキャッシュをクリアします。
npm pruneは未使用パッケージを削除するコマンドです。

$ npm cache clear
$ npm prune

もう一度shrinkwrapを実行します。

$ npm shrinkwrap
npm WARN shrinkwrap Excluding devDependency: grunt { amperize: '0.3.4',
npm WARN shrinkwrap   archiver: '1.3.0',
npm WARN shrinkwrap   bcryptjs: '2.4.3',
npm WARN shrinkwrap   bluebird: '3.4.7',.
.
.
.
wrote npm-shrinkwrap.json

上手く行きました。

参考

4
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
4
1