Wrangler publish works in terminal but fails in GH...
# workers-help
s
When I run
wrangler publish
in terminal, the app successfully deploys but when I try to do it through github worker, it doesn't. This broke after I've installed toucan.js to get some sentry monitoring in my worker. The failing step in
.github/workflows/main.yml
is :
Copy code
deploy:
    needs: run-tests
    runs-on: ubuntu-latest
    name: Deploy
    steps:
      - uses: actions/checkout@v2
      - name: Publish
        uses: cloudflare/wrangler-action@2.0.0
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
The error it throws is:
Copy code
✘ [ERROR] Could not resolve "toucan-js"

    src/index.ts:53:23:
      53 │ import { Toucan } from 'toucan-js';
         ╵                        ~~~~~~~~~~~

  You can mark the path "toucan-js" as external to exclude it from the bundle, which will remove this error.
Before that I didn't have any external dependency and my package.json is:
Copy code
{
  "name": "name",
  "version": "0.0.0",
  "devDependencies": {
    "@cloudflare/workers-types": "^3.18.0",
    "@jest/globals": "^29.5.0",
    "@types/jest": "^29.2.2",
    "@types/node": "^18.11.9",
    "@typescript-eslint/eslint-plugin": "^5.59.2",
    "@typescript-eslint/parser": "^5.59.2",
    "eslint": "^8.39.0",
    "ts-jest": "^29.1.0",
    "typescript": "^4.8.4",
    "wrangler": "^2.18.0"
  },
  "private": true,
  "scripts": {
    "dev": "wrangler dev",
    "deploy": "wrangler publish",
    "test": "jest",
    "lint": "eslint . --ext .ts"
  },
  "dependencies": {
    "toucan-js": "^3.1.0"
  }
}
Any idea what am I doing wrong? How can I mark
toucan-js
as external?
k
Sounds like your GH Action isn't doing
npm install
?
or
npm ci
s
Thank you @kian, gonna test it now
k
you can add
preCommands: npm ci
below your
apiToken
under
with
(
npm ci
if you have a package.json lockfile committed,
npm install
if not)
s
that fixed it, thank you so much! haha can't believe I've missed that
Would this be different than adding it as preCommand?:
Copy code
deploy:
    needs: run-tests
    runs-on: ubuntu-latest
    name: Deploy
    steps:
      - uses: actions/checkout@v2
      - run: npm ci
      - name: Publish
        uses: cloudflare/wrangler-action@2.0.0
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
k
Not particularly
s
all right, nice one! Thank you ❤️