Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use import statement outside a module #91

Open
bennypowers opened this issue Feb 11, 2022 · 1 comment
Open

Cannot use import statement outside a module #91

bennypowers opened this issue Feb 11, 2022 · 1 comment

Comments

@bennypowers
Copy link
Contributor

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

@crutchcorn
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants