0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

karma init でエラーになる

Posted at

環境

  • Node.js@15.3.0
  • karma@6.3.17
  • karma-cli

事象

  • karma-cli をグローバルにインストール後、karma 公式に記載されている通りにkarma init を実行しても、エラー「node:internal/modules/cjs/loader:922」が出力され、初期化処理が実行されない
console.log
$ karma init
node:internal/modules/cjs/loader:922
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\Git\Users\***\AppData\Local\Temp\fnm_multishells\89596_1648101114983\node_modules\karma-cli\bin\karma'
?[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)?[39m
?[90m    at Function.Module._load (node:internal/modules/cjs/loader:763:27)?[39m
?[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)?[39m
?[90m    at node:internal/main/run_main_module:17:47?[39m {
  code: ?[32m'MODULE_NOT_FOUND'?[39m,
  requireStack: []
}

※ 一部マスキング

結論

  • karma のローカルインストール先相対パスを指定して実行する
console.log
$ ./node_modules/karma/bin/karma init

~・~・~ 中略 ~・~・~

RequireJS bootstrap file generated at "C:\Users\???\test-main.js".
Config file generated at "C:\Users\***\karma.conf.js".

個人的な見解

  • ログに出力されるフルパスがC:\Program Files\Git\***から始まってる事から、公式セットアップ方法はkarmaをグローバルにインストールする前提になっている。しかし、同ページ内でローカルインストールを推奨しておいて、そりゃねぇだろ(ただの愚痴)
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?