admin管理员组文章数量:1194938
I am working on a Next.js project that uses the pdf-lib
library to generate or modify PDFs, and I'm using @pdf-lib/fontkit
for font support. Locally, everything works fine, and the application builds successfully using pnpm. However, when running the build in GitHub Actions, I encounter the following errors:
I'm using pnpm as my package manager, and I have committed both pnpm-lock.yaml and package.json to the repository. Here is some relevant information:
- Local Environment: macOS, Node.js v20.x, pnpm v10
- CI Environment: GitHub Actions (default ubuntu-latest runner)
- Build Command: pnpm install && pnpm build
- Next.js Version: 13.x (with App Router)
my package.json
"dependencies": {
....
"@pdf-lib/fontkit": "^1.1.1",
"@types/node": "^20.10.4",
"@types/react": "^18.2.42",
"next": "13.1.1",
"pdf-lib": "^1.17.1",
...
}
my github action script
on:
push:
jobs:
checkout-code:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
setup-node:
runs-on: ubuntu-20.04
needs: checkout-code
strategy:
matrix:
node-version: [21.x]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
with:
version: 10
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- uses: actions/checkout@v3
- name: Install dependencies
run: pnpm install
- name: Cache node_modules
uses: actions/[email protected]
with:
path: node_modules
key: wm-node-modules
restore-keys: |
wm-node-modules
......
build:
runs-on: ubuntu-20.04
needs: [test, lint, prettier]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
with:
version: 10
- name: Restore node_modules cache
uses: actions/cache@v3
with:
path: node_modules
key: wm-node-modules
- name: Build
run: pnpm build
The result:
I am working on a Next.js project that uses the pdf-lib
library to generate or modify PDFs, and I'm using @pdf-lib/fontkit
for font support. Locally, everything works fine, and the application builds successfully using pnpm. However, when running the build in GitHub Actions, I encounter the following errors:
I'm using pnpm as my package manager, and I have committed both pnpm-lock.yaml and package.json to the repository. Here is some relevant information:
- Local Environment: macOS, Node.js v20.x, pnpm v10
- CI Environment: GitHub Actions (default ubuntu-latest runner)
- Build Command: pnpm install && pnpm build
- Next.js Version: 13.x (with App Router)
my package.json
"dependencies": {
....
"@pdf-lib/fontkit": "^1.1.1",
"@types/node": "^20.10.4",
"@types/react": "^18.2.42",
"next": "13.1.1",
"pdf-lib": "^1.17.1",
...
}
my github action script
on:
push:
jobs:
checkout-code:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
setup-node:
runs-on: ubuntu-20.04
needs: checkout-code
strategy:
matrix:
node-version: [21.x]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
with:
version: 10
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- uses: actions/checkout@v3
- name: Install dependencies
run: pnpm install
- name: Cache node_modules
uses: actions/[email protected]
with:
path: node_modules
key: wm-node-modules
restore-keys: |
wm-node-modules
......
build:
runs-on: ubuntu-20.04
needs: [test, lint, prettier]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
with:
version: 10
- name: Restore node_modules cache
uses: actions/cache@v3
with:
path: node_modules
key: wm-node-modules
- name: Build
run: pnpm build
The result:
Share Improve this question edited Jan 27 at 13:18 stm 6881 gold badge6 silver badges24 bronze badges asked Jan 23 at 18:47 MixkoMixko 6231 gold badge6 silver badges12 bronze badges1 Answer
Reset to default -1First, please check Node.js versions - update your GitHub actions matrix to use Node.js v20 to match your local environment:
strategy:
matrix:
node-version: [20.x]
Ensure pnpm-lock.yaml is up-to-date:
pnpm install
pnpm dedupe
pnpm prune
(Commit any changes to the lock file)
Set NODE_ENV for Production, explicitly set NODE_ENV=production in the build step:
- name: Build
run: NODE_ENV=production pnpm build
And last, check font compatibility (just to be sure) : verify your font setup with @pdf-lib/fontkit and ensure fonts are properly bundled or dynamically loaded
本文标签:
版权声明:本文标题:reactjs - Next.js Build Fails in GitHub Actions: Module not found: Can't resolve 'pdf-lib' and @pdf-libf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738473149a2088706.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论