SSR build failing on Vercel with error Cannot find module 'sharp'
See original GitHub issueSSR build failing on Vercel with error Cannot find module 'sharp'
Probably related to https://github.com/nuxt/image/issues/430
Using this vercel.json:
{
"version": 2,
"routes": [
{
"src": "/api/subscribe",
"dest": "/api/subscribe.js"
}
],
"builds": [
{
"src": "api/**/*.js",
"use": "@vercel/node"
},
{
"src": "nuxt.config.js",
"use": "@nuxtjs/vercel-builder",
"config": {
"serverFiles": [
"project.config.js",
"api/**"
]
}
}
]
}
Here is the complete build log:
15:38:32.209 | Cloning github.com/riccardolardi/garcoa-nuxt (Branch: master, Commit: fb74248)
-- | --
15:38:33.292 | Cloning completed: 1.082s
15:38:33.323 | Analyzing source code...
15:38:33.336 | Warning: Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
15:38:34.633 | Installing build runtime...
15:38:35.399 | Build runtime installed: 765.535ms
15:38:36.562 | Installing build runtime...
15:38:39.779 | Build runtime installed: 3.217s
15:38:42.736 | Looking up build cache...
15:38:45.017 | Build cache downloaded [31.16 MB]: 2071.738ms
15:38:46.536 | Installing dependencies...
15:38:46.850 | yarn install v1.22.11
15:38:46.892 | info No lockfile found.
15:38:46.903 | [1/4] Resolving packages...
15:38:52.415 | warning @nuxtjs/svg > vue-svg-loader > svg-to-vue > svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
15:38:52.530 | warning babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
15:38:53.579 | warning mailchimp-api-v3 > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
15:38:53.609 | warning mailchimp-api-v3 > request > har-validator@5.1.5: this library is no longer supported
15:38:53.636 | warning mailchimp-api-v3 > request > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
15:38:55.494 | warning nuxt > @nuxt/babel-preset-app > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
15:38:56.625 | warning nuxt > @nuxt/webpack > webpack-hot-middleware > querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
15:38:56.852 | warning nuxt > @nuxt/webpack > cssnano > cssnano-preset-default > postcss-svgo > svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
15:38:57.060 | warning nuxt > @nuxt/webpack > webpack > node-libs-browser > url > querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
15:38:57.061 | warning nuxt > @nuxt/webpack > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
15:38:57.064 | warning nuxt > @nuxt/webpack > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
15:38:57.192 | warning nuxt > @nuxt/webpack > postcss-preset-env > postcss-color-hex-alpha > postcss-values-parser > flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
15:38:57.334 | warning nuxt > @nuxt/webpack > webpack > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
15:38:57.337 | warning nuxt > @nuxt/webpack > webpack > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
15:38:58.513 | [2/4] Fetching packages...
15:39:22.324 | info fsevents@2.3.2: The platform "linux" is incompatible with this module.
15:39:22.324 | info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
15:39:22.329 | info fsevents@1.2.13: The platform "linux" is incompatible with this module.
15:39:22.330 | info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
15:39:22.336 | [3/4] Linking dependencies...
15:39:22.341 | warning "@nuxtjs/eslint-config > eslint-plugin-jest > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 \|\| >= 3.2.0-dev \|\| >= 3.3.0-dev \|\| >= 3.4.0-dev \|\| >= 3.5.0-dev \|\| >= 3.6.0-dev \|\| >= 3.6.0-beta \|\| >= 3.7.0-dev \|\| >= 3.7.0-beta".
15:39:22.342 | warning "@nuxtjs/eslint-module > eslint-webpack-plugin@2.5.4" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:39:22.342 | warning "@nuxtjs/moment > moment-locales-webpack-plugin@1.2.0" has unmet peer dependency "webpack@^1 \|\| ^2 \|\| ^3 \|\| ^4 \|\| ^5".
15:39:22.342 | warning "@nuxtjs/moment > moment-timezone-data-webpack-plugin@1.5.0" has unmet peer dependency "webpack@4.x.x \|\| 5.x.x".
15:39:22.343 | warning "@nuxtjs/stylelint-module > stylelint-webpack-plugin@2.2.2" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:39:22.343 | warning "@nuxtjs/svg > url-loader@4.1.1" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:39:22.343 | warning "@nuxtjs/svg > file-loader@6.2.0" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:39:22.343 | warning "@nuxtjs/svg > raw-loader@4.0.2" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:39:22.344 | warning "@nuxtjs/svg > vue-svg-loader@0.16.0" has unmet peer dependency "vue-template-compiler@^2.0.0".
15:39:22.344 | warning "@nuxtjs/svg > vue-svg-loader > svg-to-vue@0.7.0" has unmet peer dependency "vue-template-compiler@^2.0.0".
15:39:22.344 | warning "nuxt > @nuxt/components@2.2.1" has unmet peer dependency "consola@*".
15:39:22.351 | warning " > sass-loader@10.2.0" has unmet peer dependency "webpack@^4.36.0 \|\| ^5.0.0".
15:39:22.352 | warning " > vue-awesome-swiper@4.1.1" has incorrect peer dependency "swiper@^5.2.0".
15:39:22.352 | warning " > vue-awesome-swiper@4.1.1" has unmet peer dependency "vue@2.x".
15:39:33.446 | [4/4] Building fresh packages...
15:39:35.628 | success Saved lockfile.
15:39:35.633 | Done in 48.79s.
15:39:38.173 | Uploading build outputs...
15:39:39.590 | Deploying build outputs...
15:39:43.489 | Looking up build cache...
15:39:54.729 | Build cache downloaded [212.60 MB]: 11064.510ms
15:39:56.063 | [log] Running with @nuxt/vercel-builder version 0.22.1
15:39:56.064 | [log] ----------------- Prepare build -----------------
15:39:56.064 | [log] Downloading files...
15:39:56.064 | [log] Working directory: /vercel/path1
15:39:56.069 | [log] Using yarn
15:39:56.070 | [info] Prepare build took: 6.384821 ms
15:39:56.070 | [log] ----------------- Install devDependencies -----------------
15:39:56.070 | [log] Using cached node_modules_dev
15:39:58.167 | yarn install v1.22.11
15:39:58.295 | [1/5] Resolving packages...
15:39:59.011 | [2/5] Fetching packages...
15:40:01.050 | info fsevents@2.3.2: The platform "linux" is incompatible with this module.
15:40:01.050 | info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
15:40:01.064 | info fsevents@1.2.13: The platform "linux" is incompatible with this module.
15:40:01.064 | info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
15:40:01.070 | [3/5] Linking dependencies...
15:40:01.075 | warning "@nuxtjs/eslint-config > eslint-plugin-jest > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 \|\| >= 3.2.0-dev \|\| >= 3.3.0-dev \|\| >= 3.4.0-dev \|\| >= 3.5.0-dev \|\| >= 3.6.0-dev \|\| >= 3.6.0-beta \|\| >= 3.7.0-dev \|\| >= 3.7.0-beta".
15:40:01.076 | warning "@nuxtjs/eslint-module > eslint-webpack-plugin@2.5.4" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:40:01.076 | warning "@nuxtjs/moment > moment-locales-webpack-plugin@1.2.0" has unmet peer dependency "webpack@^1 \|\| ^2 \|\| ^3 \|\| ^4 \|\| ^5".
15:40:01.076 | warning "@nuxtjs/moment > moment-timezone-data-webpack-plugin@1.5.0" has unmet peer dependency "webpack@4.x.x \|\| 5.x.x".
15:40:01.076 | warning "@nuxtjs/stylelint-module > stylelint-webpack-plugin@2.2.2" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:40:01.077 | warning "@nuxtjs/svg > file-loader@6.2.0" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:40:01.077 | warning "@nuxtjs/svg > raw-loader@4.0.2" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:40:01.077 | warning "@nuxtjs/svg > url-loader@4.1.1" has unmet peer dependency "webpack@^4.0.0 \|\| ^5.0.0".
15:40:01.077 | warning "@nuxtjs/svg > vue-svg-loader@0.16.0" has unmet peer dependency "vue-template-compiler@^2.0.0".
15:40:01.077 | warning "@nuxtjs/svg > vue-svg-loader > svg-to-vue@0.7.0" has unmet peer dependency "vue-template-compiler@^2.0.0".
15:40:01.078 | warning "nuxt > @nuxt/components@2.2.1" has unmet peer dependency "consola@*".
15:40:01.088 | warning " > sass-loader@10.2.0" has unmet peer dependency "webpack@^4.36.0 \|\| ^5.0.0".
15:40:01.092 | warning " > vue-awesome-swiper@4.1.1" has incorrect peer dependency "swiper@^5.2.0".
15:40:01.092 | warning " > vue-awesome-swiper@4.1.1" has unmet peer dependency "vue@2.x".
15:40:06.298 | [4/5] Building fresh packages...
15:40:09.694 | warning Error running install script for optional dependency: "/vercel/path1/node_modules/sharp: Command failed.
15:40:09.694 | Exit code: 1
15:40:09.695 | Command: (node install/libvips && node install/dll-copy && prebuild-install) \|\| (node install/can-compile && node-gyp rebuild && node install/dll-copy)
15:40:09.695 | Arguments:
15:40:09.695 | Directory: /vercel/path1/node_modules/sharp
15:40:09.695 | Output:
15:40:09.695 | sharp: Using cached /vercel/.npm/_libvips/libvips-8.11.3-linux-x64.tar.br
15:40:09.695 | /bin/sh: prebuild-install: command not found
15:40:09.695 | gyp info it worked if it ends with ok
15:40:09.695 | gyp info using node-gyp@5.1.0
15:40:09.695 | gyp info using node@14.17.6 \| linux \| x64
15:40:09.695 | gyp info find Python using Python version 2.7.18 found at \"/usr/bin/python\"
15:40:09.695 | gyp http GET https://nodejs.org/download/release/v14.17.6/node-v14.17.6-headers.tar.gz
15:40:09.696 | gyp http 200 https://nodejs.org/download/release/v14.17.6/node-v14.17.6-headers.tar.gz
15:40:09.696 | gyp http GET https://nodejs.org/download/release/v14.17.6/SHASUMS256.txt
15:40:09.696 | gyp http 200 https://nodejs.org/download/release/v14.17.6/SHASUMS256.txt
15:40:09.696 | gyp info spawn /usr/bin/python
15:40:09.696 | gyp info spawn args [
15:40:09.696 | gyp info spawn args '/node14/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
15:40:09.696 | gyp info spawn args 'binding.gyp',
15:40:09.696 | gyp info spawn args '-f',
15:40:09.696 | gyp info spawn args 'make',
15:40:09.696 | gyp info spawn args '-I',
15:40:09.696 | gyp info spawn args '/vercel/path1/node_modules_dev/sharp/build/config.gypi',
15:40:09.696 | gyp info spawn args '-I',
15:40:09.696 | gyp info spawn args '/node14/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
15:40:09.697 | gyp info spawn args '-I',
15:40:09.697 | gyp info spawn args '/vercel/.cache/node-gyp/14.17.6/include/node/common.gypi',
15:40:09.697 | gyp info spawn args '-Dlibrary=shared_library',
15:40:09.697 | gyp info spawn args '-Dvisibility=default',
15:40:09.697 | gyp info spawn args '-Dnode_root_dir=/vercel/.cache/node-gyp/14.17.6',
15:40:09.697 | gyp info spawn args '-Dnode_gyp_dir=/node14/lib/node_modules/npm/node_modules/node-gyp',
15:40:09.697 | gyp info spawn args '-Dnode_lib_file=/vercel/.cache/node-gyp/14.17.6/<(target_arch)/node.lib',
15:40:09.697 | gyp info spawn args '-Dmodule_root_dir=/vercel/path1/node_modules_dev/sharp',
15:40:09.699 | gyp info spawn args '-Dnode_engine=v8',
15:40:09.699 | gyp info spawn args '--depth=.',
15:40:09.699 | gyp info spawn args '--no-parallel',
15:40:09.699 | gyp info spawn args '--generator-output',
15:40:09.699 | gyp info spawn args 'build',
15:40:09.699 | gyp info spawn args '-Goutput_dir=.'
15:40:09.700 | gyp info spawn args ]
15:40:09.700 | gyp info spawn make
15:40:09.700 | gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
15:40:09.700 | make: Entering directory `/vercel/path1/node_modules_dev/sharp/build'
15:40:09.700 | CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
15:40:09.700 | AR(target) Release/obj.target/../node-addon-api/nothing.a
15:40:09.700 | COPY Release/nothing.a
15:40:09.700 | TOUCH Release/obj.target/libvips-cpp.stamp
15:40:09.700 | CXX(target) Release/obj.target/sharp-linux-x64/src/common.o
15:40:09.700 | ../src/common.cc:24:10: fatal error: vips/vips8: No such file or directory
15:40:09.700 | #include <vips/vips8>
15:40:09.700 | ^~~~~~~~~~~~
15:40:09.701 | compilation terminated.
15:40:09.701 | make: *** [Release/obj.target/sharp-linux-x64/src/common.o] Error 1
15:40:09.701 | make: Leaving directory `/vercel/path1/node_modules_dev/sharp/build'
15:40:09.701 | gyp ERR! build error
15:40:09.701 | gyp ERR! stack Error: `make` failed with exit code: 2
15:40:09.701 | gyp ERR! stack at ChildProcess.onExit (/node14/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
15:40:09.701 | gyp ERR! stack at ChildProcess.emit (events.js:400:28)
15:40:09.701 | gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
15:40:09.701 | gyp ERR! System Linux 4.14.243-185.433.amzn2.x86_64
15:40:09.701 | gyp ERR! command \"/node14/bin/node\" \"/node14/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
15:40:09.701 | gyp ERR! cwd /vercel/path1/node_modules_dev/sharp
15:40:09.702 | gyp ERR! node -v v14.17.6
15:40:09.702 | gyp ERR! node-gyp -v v5.1.0
15:40:09.702 | gyp ERR! not ok"
15:40:09.702 | info This module is OPTIONAL, you can safely ignore this error
15:40:09.947 | [5/5] Cleaning modules...
15:40:13.832 | Done in 15.67s.
15:40:13.860 | [info] Install devDependencies took: 17789.283915 ms
15:40:13.860 | [log] ----------------- Nuxt build -----------------
15:40:14.136 | [log] Running nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path1
15:40:14.881 | [error] [@nuxt/image] `ipx` is an optional dependency for local image optimization and is not properly installed. Please try `npm install` or `yarn install` again.
15:40:14.883 | [fatal] Error: Cannot find module 'sharp'
15:40:14.883 | Require stack:
15:40:14.883 | - /vercel/path1/node_modules_dev/ipx/dist/index.cjs
15:40:14.883 | - /vercel/path1/node_modules_dev/@nuxt/image/dist/module.js
15:40:14.883 | - /vercel/path1/node_modules_dev/@nuxt/core/dist/core.js
15:40:14.883 | Require stack:
15:40:14.884 | - node_modules_dev/ipx/dist/index.cjs
15:40:14.884 | - node_modules_dev/@nuxt/image/dist/module.js
15:40:14.884 | - node_modules_dev/@nuxt/core/dist/core.js
15:40:14.884 | at node_modules_dev/@nuxt/image/dist/module.js:132:13
15:40:14.884 | at async Object.ipxSetup [as setup] (node_modules_dev/@nuxt/image/dist/module.js:130:48)
15:40:14.884 | at async ModuleContainer.imageModule2 (node_modules_dev/@nuxt/image/dist/module.js:271:7)
15:40:14.884 | at async ModuleContainer.addModule (node_modules_dev/@nuxt/core/dist/core.js:239:20)
15:40:14.884 | at async ModuleContainer.ready (node_modules_dev/@nuxt/core/dist/core.js:55:5)
15:40:14.884 | at async Nuxt._init (node_modules_dev/@nuxt/core/dist/core.js:478:5)
15:40:14.892 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
15:40:14.892 | โ โ
15:40:14.892 | โ โ Nuxt Fatal Error โ
15:40:14.892 | โ โ
15:40:14.892 | โ Error: Error: Cannot find module 'sharp' โ
15:40:14.892 | โ Require stack: โ
15:40:14.892 | โ - /vercel/path1/node_modules_dev/ipx/dist/index.cjs โ
15:40:14.892 | โ - /vercel/path1/node_modules_dev/@nuxt/image/dist/module.js โ
15:40:14.893 | โ - /vercel/path1/node_modules_dev/@nuxt/core/dist/core.js โ
15:40:14.893 | โ โ
15:40:14.893 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
15:40:14.904 | Error: Command failed with exit code 1: npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path1
15:40:14.904 | at makeError (/vercel/bde74988fa2cf27a/.build-utils/.builder/node_modules/execa/lib/error.js:60:11)
15:40:14.904 | at handlePromise (/vercel/bde74988fa2cf27a/.build-utils/.builder/node_modules/execa/index.js:118:26)
15:40:14.904 | at processTicksAndRejections (internal/process/task_queues.js:95:5)
15:40:14.905 | at Object.build (/vercel/bde74988fa2cf27a/.build-utils/.builder/node_modules/@nuxtjs/vercel-builder/lib/index.js:347:3)
15:40:14.905 | at buildStep (/var/task/webpack:/@vercel/api/scripts/build-container/src/utils/purpose-build.ts:161:1) {
15:40:14.905 | shortMessage: 'Command failed with exit code 1: npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path1',
15:40:14.905 | command: 'npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path1',
15:40:14.905 | escapedCommand: 'npx nuxt build --standalone --no-lock "--config-file \\"nuxt.config.js\\"" "/vercel/path1"',
15:40:14.905 | exitCode: 1,
15:40:14.905 | signal: undefined,
15:40:14.905 | signalDescription: undefined,
15:40:14.905 | stdout: undefined,
15:40:14.906 | stderr: undefined,
15:40:14.906 | failed: true,
15:40:14.906 | timedOut: false,
15:40:14.906 | isCanceled: false,
15:40:14.906 | killed: false
15:40:14.906 | }
15:40:19.889 | Build completed. Populating build cache...
15:40:35.567 | Uploading build cache [31.16 MB]...
15:40:36.389 | Build cache uploaded: 821.685ms
15:40:36.914 | Done with "api/subscribe.js"
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top Results From Across the Web
How to fix Next.js Vercel deployment module not found error
I think it may be an internal issue with Vercel's deployment infrastructure. Notice the line it is failing on: Error: Cannot find module...
Read more >sharp-missing-in-production - Next.js
You are seeing this error because Image Optimization in production mode ( next start ) was detected. For a production environment using output:...
Read more >No Next.js version could be detected in your project. Make sure
When a blitz app is deployed on Vercel with PNPM, Vercel cannot detect the next.js version and ultimately fails to build the app....
Read more >Gatsby Changelog | 5.3.0
ES Modules (ESM) in Gatsby files; Improved error messages ... gatsby-source-drupal : Fix not found image urls failing builds, via PR #35855ย ...
Read more >How to Disable Server-Side Rendering (SSR) in Next.js
js does not work without server-side rendering (SSR) by default. I preferred using a non-SSR solution like Create React App, when my app...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi folks, Iโm facing this exactly problem too. Apparently itโs something related with version
"@nuxt/image": "0.6.1"
, This is working well with version"@nuxt/image": "0.4.17"
Hope it helps!
oh yes i did forgot to change my node version to 14 instead of 12. Thanks my bad.