typescript - How to fix GitHub building "unknown token" error in yarn.lock for GitHub Pages? - Stack Overflow

admin2025-04-30  0

I tried deploying a web-project for GitHub pages, unfortunately I am failing in the building process.
The error is stating there is an unknown token in line 1541 in yarn.lock . The attached snipped shows there isn't. Please advise how to proceed and successfully deploy the project.

Error during GitHub Actions building:

Run yarn
  yarn
  shell: /usr/bin/bash -e {0}
yarn install v1.22.22
error SyntaxError: Unknown token: { line: 1541, col: 40, type: 'COLON', value: undefined } 1541:40 in /home/runner/work/sa-skins/sa-skins/yarn.lock
    at Parser.unexpected (/usr/local/lib/node_modules/yarn/lib/cli.js:64026:11)
    at Parser.parse (/usr/local/lib/node_modules/yarn/lib/cli.js:64157:14)
    at Parser.parse (/usr/local/lib/node_modules/yarn/lib/cli.js:64131:26)
    at parse (/usr/local/lib/node_modules/yarn/lib/cli.js:64231:21)
    at module.exports.exports.default (/usr/local/lib/node_modules/yarn/lib/cli.js:63793:96)
    at Function.<anonymous> (/usr/local/lib/node_modules/yarn/lib/cli.js:3068:63)
    at Generator.next (<anonymous>)
    at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:321:13
info Visit  for documentation about this command.
Error: Process completed with exit code 1.

Yarn.lock:

1540: [email protected]:
1541: version "1.8.1"
1542:  resolved " 1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
1543:  integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=

tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "baseUrl": ".",
    "downlevelIteration": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

package.json

{
  "name": "sa-skins",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "export": "next build && next export",
    "deploy": "gh-pages -d out"
  },
  "dependencies": {
    "@emotion/react": "^11.7.1",
    "@emotion/styled": "^11.6.0",
    "@mui/icons-material": "^5.2.5",
    "@mui/material": "^5.2.6",
    "next": "12.0.7",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "three": "^0.136.0"
  },
  "devDependencies": {
    "@types/node": "17.0.5",
    "@types/react": "17.0.38",
    "@types/three": "^0.135.0",
    "eslint": "8.6.0",
    "eslint-config-next": "12.0.7",
    "eslint-plugin-prettier": "^4.0.0",
    "gh-pages": "^3.2.3",
    "prettier": "^2.5.1",
    "typescript": "4.5.4"
  }
}

.github/workflows/ci.yml

name: CI/CD

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '16'
          cache: 'yarn'
      - run: yarn
      - run: yarn export
      - if: ${{ github.event_name == 'push' }} 
        name: Deploy with gh-pages
        run: |
          git remote set-url origin https://git:${GITHUB_TOKEN}@github/${GITHUB_REPOSITORY}.git
          yarn deploy -u "github-actions-bot <[email protected]>"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Full code:

转载请注明原文地址:http://anycun.com/QandA/1746024117a91494.html