LoginSignup
7
2

More than 5 years have passed since last update.

CircleCIでのnodeで Module Not Foundが出たときの対処法

Posted at

tl;dr

パスの指定はちゃんとしましょう。

問題

プロジェクトのテストをCircleCIで回していて、手元では動くテストがCircleCI上だと以下のようなエラーが出てしまっていました。

npm test

[10:48:53] Using gulpfile ~/porject/gulpfile.js
[10:48:53] Starting 'test'...
[10:48:59] 'test' errored after 5.7 s
[10:48:59] Error in plugin 'gulp-mocha'
Message:
    Cannot find module 'path/to/module/Hogehoge.js'
Details:
    code: MODULE_NOT_FOUND
Stack:
Error: Cannot find module 'path/to/module/Hogehoge.js'

解決法

requireで指定していたパスのファイル名の先頭が大文字になっていてファイルと違っていました....orz
ファイル名を実態を合わせて指定したら動きました。

理由

OSのファイルシステムに依存するようです。macとCircleCI上のOSで挙動が違っていたみたいです。
参考:http://stackoverflow.com/questions/13617863/can-i-force-node-js-require-to-be-case-sensitive

あんまりないかもしれませんが、macとlinux系のOS両方で開発していると起こるかもしれないですね。

7
2
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
7
2