I am trying to release a package to npm.
When CircleCI is trying to run semantic-release
it throws the following error:
/home/circleci/src/node_modules/semantic-release/node_modules/execa/index.js:18
const env = extendEnv ? {...process.env, ...envOption} : envOption;
^^^
SyntaxError: Unexpected token ...
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/src/node_modules/semantic-release/bin/semantic-release.js:9:13)
at Module._compile (module.js:541:32)
npm ERR! code ELIFECYCLE
My package.json
devDependencies are as follows:
"devDependencies": {
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.0.7",
"@semantic-release/npm": "^7.0.5",
"@semantic-release/release-notes-generator": "^9.0.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"jest": "^25.5.1",
"marked": "^0.4.0",
"npm-audit-resolver": "^2.2.0",
"prettier": "^2.0.5",
"semantic-release": "^16.0.4",
"semantic-release-cli": "^5.3.1"
},
I have set up environment variables for github and npm in CircleCI and have used them in my CircleCI config file. I have also have npm ci
step before running semantic-release
in my CircleCI config.
Wondering if anyone has encountered this issue and have resolved this? (I can provide more information in case needed. )
I resolved the problem myself. I suspected that the problem is due to some version incompatibities of semantic-release
plugins that I was using with the library. I tried different versions of semantic-release
but I had no success.
Finally, I checked the Nodejs version (node --version
) of my CircleCI executor which was a machine executor (image: ubuntu-1604:201903-01
). I found that the node version in that executor was so old (v6.x.x
). I needed that machine executor to run my tests as I had to mock some aws features through other docker images running on the machine. However, could change the executor to a Nodejs docker executor for the release
step. So, I did this and problem was resolved.
For example, I added something like the following at the beginning of my CircleCI config:
version: 2.1
default_executor: &default_executor
working_directory: ~/repo
machine:
image: ubuntu-1604:201903-01
release_executor: &release_executor
working_directory: ~/repo
docker:
- image: circleci/node:10.18
Then, in the release
step I did this before running the npm run semantic-release
:
release:
<<: *release_executor
Hopefully, this solution will help others as well :)