karma 4.0.1 to start the test and successfully test out the specs. While it works fine locally (osx), for some reason it's failing in CI environment.
#!/bin/bash -eo pipefail
cd spec_js
if [ "$CIRCLE_NODE_INDEX" -eq 2 ]; then npm install && npm run test-ci; fi
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 372 packages in 10.533s
> [email protected] test-ci /home/circleci/project/spec_js
> ./node_modules/karma/bin/karma start ./karma.conf.js
/home/circleci/project/spec_js/node_modules/karma/lib/server.js:118
async start () {
^^^^^
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:511:25)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/circleci/project/spec_js/node_modules/karma/lib/cli.js:8:16)
at Module._compile (module.js:541:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test-ci: `./node_modules/karma/bin/karma start ./karma.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test-ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2019-03-15T05_32_20_835Z-debug.log
Exited with code 1
v11.6.0 (npm v6.5.0-next.0)4.0.1karma.config.js file/// karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai', 'sinon'],
plugins: [
'karma-chrome-launcher',
'karma-mocha',
'karma-chai',
'karma-sinon',
'karma-string-replace-preprocessor'
],
files: [
'jquery.js',
'../pages.js',
'pages-spec.js'
],
exclude: [],
preprocessors: {
'../pages.js': ['stringreplace']
},
stringReplacePreprocessor: {
patterns: [
{ match: 'process.env.HOST', replacement: '"https://www.host.com"' },
]
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Chrome'],
singleRun: true
});
};
The most likely explanation is that your CircleCI is running node < 6.
I had that reasoning too. but I get this while debugging.
#!/bin/bash -eo pipefail
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v11.6.0
nvm alias default v11.6.0
npm -v
Downloading https://nodejs.org/dist/v11.6.0/node-v11.6.0-linux-x64.tar.xz...
######################################################################## 100.0%
Now using node v11.6.0 (npm v6.5.0-next.0)
default -> v11.6.0
6.5.0-next.0
Try putting this in your karma.config.js
console.log(`Version: ${process.version}`);
Or even better open /home/circleci/project/spec_js/node_modules/karma/lib/server.js:118 and put the log there.
I have a latest 6.x node (6.17.0) and get exactly same error.
@yrtimiD Use karma 3.x for node 6.x.
Closing this issue, since for some reason Circle CI wasn't using the desired node version. Can confirm that it's a node 6.x issue. Thanks a lot for responding.
to resolve: yarn add [email protected]
Most helpful comment
The most likely explanation is that your CircleCI is running node < 6.