title: Karma not running in Jenkins CI, Cannot find module 'karma-jasmine'
body: <p>I'm setting up an Angular 4 SPA with automatic testing in Jenkins CI. The SPA is part of a larger, Maven-managed project, so the build is also Maven-managed. So far I've:</p>
  
  <ol>
  <li>Installed the NodeJS plugin on Jenkins, using install from nodejs.org with version 8.6.0</li>
  <li>Configured "Global npm packages to install" = "karma-cli phantomjs-prebuilt jasmine-core karma-jasmine karma-phantomjs-launcher karma-junit-reporter karma-coverage"</li>
  <li>Added the "maven-karma-plugin" in pom.xml with browsers=PhantomJS / singleRun=true / reporters=dots,junit</li>
  <li>Enabled "Provide Node &amp; npm bin/ folder to PATH" on the Jenkins job configuration </li>
  </ol>
  
  <p>The build process starts up quite ok, but eventually I get:</p>
  
  <pre><code>[INFO] --- maven-karma-plugin:1.6:start (default) @ webclient ---
  [INFO] Executing Karma Test Suite ...
  /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/karma start /var/lib/jenkins/workspace/funnel_build/webclient/karma.conf.js --browsers PhantomJS --reporters dots,junit --single-run
  07 10 2017 17:07:52.801:ERROR [config]: Error in config file! 
   { Error: Cannot find module 'karma-jasmine' 
      at Function.Module._resolveFilename (module.js:527:15) 
      at Function.Module._load (module.js:476:23) 
      at Module.require (module.js:568:17) 
      at require (internal/module.js:11:18) 
      at module.exports (/var/lib/jenkins/workspace/funnel_build/webclient/karma.conf.js:9:7) 
      at Object.parseConfig (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/karma/lib/config.js:410:5)
  </code></pre>
  
  <p>The npm install at the very beginning of the build logs:</p>
  
  <pre><code>$ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/npm install -g karma-cli phantomjs-prebuilt jasmine-core karma-jasmine karma-phantomjs-launcher karma-junit-reporter karma-coverage
  /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/karma -&gt; /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/karma-cli/bin/karma
  /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/phantomjs -&gt; /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/bin/phantomjs
  
  &gt; phantomjs-prebuilt@2.1.15 install /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt
  &gt; node install.js
  
  Considering PhantomJS found at /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/phantomjs
  Looks like an `npm install -g`
  Could not link global install, skipping...
  Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
  Verified checksum of previously downloaded file
  Extracting tar contents (via spawned process)
  Removing /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/lib/phantom
  Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1507388835905/phantomjs-2.1.1-linux-x86_64 -&gt; /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/lib/phantom
  Writing location.js file
  Done. Phantomjs binary available at /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
  npm WARN karma-jasmine@1.1.0 requires a peer of karma@* but none was installed.
  npm WARN karma-junit-reporter@1.2.0 requires a peer of karma@&gt;=0.9 but none was installed.
  npm WARN karma-phantomjs-launcher@1.0.4 requires a peer of karma@&gt;=0.9 but none was installed.
  
  + karma-phantomjs-launcher@1.0.4
  + karma-coverage@1.1.1
  + karma-jasmine@1.1.0
  + karma-cli@1.0.1
  + karma-junit-reporter@1.2.0
  + jasmine-core@2.8.0
  + phantomjs-prebuilt@2.1.15
  updated 7 packages in 10.553s
  </code></pre>
  
  <p>(The reason the package 'karma' is currently not on the list is that I read somewhere that karma-cli should be used in place of karma. Adding the 'karma' package doesn't change anything, however.)</p>
  
  <p>Any idea why that "Cannot find module 'karma-jasmine'" pops up? In (2) you'll see that the karma-jasmine package is listed, I find it on the server, but still it's not found by the NodeJS plugin.</p>
  
  <p>Thanks, Simon</p>