我正在使用托管的Next.JS @ Vercel创建这个站点。我使用的一个包是一个定制的包,我已经在我的项目中对它进行了分叉、更新,并且在构建之后,它能够在本地工作。我发了一个question here。
然而,部署在Vercel这边失败了,有消息抱怨我使用的那个自定义模块找不到。当地一切都很好。
14:40:04.802 Failed to compile.
14:40:04.803 ModuleNotFoundError: Module not found: Error: Can't resolve 'react-headroom' in '/vercel/path0/src/components/layout'
14:40:04.803 > Build error occurred
14:40:04.804 Error: > Build failed because of webpack errors
14:40:04.805 at /vercel/path0/node_modules/next/dist/build/index.js:17:924
14:40:04.805 at runMicrotasks (<anonymous>)
14:40:04.805 at processTicksAndRejections (internal/process/task_queues.js:95:5)
14:40:04.805 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
我相信这是由于缓存的构建从上一个版本(在我分叉和编辑我的软件包)。我遇到了一些解决方案,比如使用Vercel来清理缓存的构建,但是它似乎不起作用(vercel --force
),因为我得到了相同的错误@构建时间。
我不知道我能做些什么来解决这个问题,或者在这个过程中是否遗漏了什么。
编辑:这是我的package.json文件
{
"name": "cms-sanity",
"version": "1.0.0",
"scripts": {
"dev": "next",
"build": "npm run build:sanity && pwd && npm run build:web",
"build:web": "next build",
"start:web": "next start",
"build:sanity": "cd studio && sanity build ../public/studio -y && cd ..",
"start:sanity": "cp .env ./studio/.env.development && cd studio && sanity start",
"postinstall": "lerna bootstrap"
},
"dependencies": {
"@chakra-ui/icons": "^1.0.15",
"@chakra-ui/react": "^1.6.7",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@sanity/block-content-to-react": "^3.0.0",
"@sanity/client": "^2.8.0",
"@sanity/image-url": "^0.140.19",
"axios": "^0.22.0",
"classnames": "^2.2.6",
"date-fns": "^2.15.0",
"framer-motion": "^4",
"fs": "^0.0.1-security",
"google-spreadsheet": "^3.1.15",
"next": "^10.2.0",
"next-sanity": "^0.1.5",
"next-sanity-image": "^3.1.6",
"next-seo": "^4.26.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-headroom": "https://github.com/eduoliveira85/react-headroom/",
"react-hook-form": "^7.3.6",
"react-icons": "^4.2.0",
"react-jss": "^10.8.0",
"react-world-flags": "^1.4.0",
"swr": "^0.5.5"
},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^4.0.3",
"@sanity/cli": "^2.0.5",
"lerna": "^4.0.0",
"postcss-preset-env": "^6.7.0"
}
}
发布于 2022-01-06 13:52:43
我只将文件从repo复制到我的项目,手动安装了依赖项,从而解决了这个问题。无论如何,这个库都不需要更新。
发布于 2021-12-31 07:59:19
在您的package.json中,@react标题依赖指向一个github链接,而不是依赖版本。这似乎就是问题所在。
https://stackoverflow.com/questions/69780855
复制相似问题