首页 > 解决方案 > 运行 `npm rebuild node-sass` 以在 Github Actions 中下载当前环境的绑定

问题描述

现在我正在 Github Actions 中构建一个节点项目,这是我的 ci 脚本:

name: cernitor-ci

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.5.0
      - name: Install yarn
        uses: borales/actions-yarn@v2.3.0
        with: 
         cmd: install
      - name: Build React App
        run: |
         sudo yarn 
         sudo yarn add --check-files node-sass
         sudo npm rebuild node-sass
         yarn build

遇到Build React App块时,显示此错误:

yarn run v1.22.10
$ CI=false && react-app-rewired build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Failed to compile.

./src/style/base.scss
Error: Missing binding /home/runner/work/Cernitor/Cernitor/node_modules/node-sass/vendor/linux-x64-93/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 16.x

Found bindings for the following environments:
  - Linux 64-bit with Node.js 14.x
  - Linux/musl 64-bit with Node.js 14.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

我应该怎么做才能解决它?我已经尝试将节点升级到最新版本。重建node-sass,但似乎没有效果。

标签: javascript

解决方案


推荐阅读