semantic-release-action
semantic-release-action copied to clipboard
Cannot use import statement outside a module
Describe the bug Running a node es module via a CLI, which works under normal circumstances, fails during the "prepare" script run as part of the semantic-release-action CI flow, with the error message:
Cannot use import statement outside a module
Workflow https://github.com/bennypowers/stripe-elements/runs/5152186759?check_suite_focus=true
release.yml
name: Release
on:
push:
branches:
- master
- next
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install Dependencies
run: npm ci
- name: Install Coverage Reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Run Tests
run: npm test
- name: Format Coverage
run: ./cc-test-reporter format-coverage -t lcov -o coverage/coverage.json coverage/lcov.info
- name: Upload Coverage
uses: actions/upload-artifact@v1
with:
name: coverage
path: coverage
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
release:
name: Release
needs: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install dependencies
run: npm ci
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic # Need an `id` for output variables
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
upload-coverage:
name: Upload Coverage
runs-on: ubuntu-latest
needs:
- Test
- Release
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Download coverage
uses: actions/download-artifact@v1
with:
name: coverage
- name: Install Coverage Reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: Upload Coverage
run: ./cc-test-reporter upload-coverage -i coverage/coverage.json
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
Expected behavior Build proceeds as expected
Additional context
There's an nvmrc with v16.13.0
and "type": "module"
in both the project root's package.json and the cli package's package.json
@bennypowers have you happened to fix this issue?
I'm running into the same here:
https://github.com/crutchcorn/houseform/actions/runs/4109368281/jobs/7091406259