image icon indicating copy to clipboard operation
image copied to clipboard

not building in vercel

Open treboryx opened this issue 2 years ago • 7 comments

Using the latest version of nuxt/image. It will not build on vercel. Tried both yarn and npm.

08:18:56.087  	Cloning completed: 1.572s
08:18:56.242  	Analyzing source code...
08:18:56.261  	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
08:18:57.565  	Installing build runtime...
08:18:58.409  	Build runtime installed: 843.613ms
08:19:07.316  	Looking up build cache...
08:19:11.108  	Build cache downloaded [52.49 MB]: 3532.751ms
08:19:12.687  	Installing dependencies...
08:19:12.705  	Detected `package-lock.json` generated by npm 7...
08:19:31.180  	npm WARN deprecated [email protected]: The zlib module provides APIs for brotli compression/decompression starting with Node.js v10.16.0, please use it over iltorb
08:19:55.594  	added 584 packages, removed 302 packages, and changed 89 packages in 43s
08:19:55.595  	289 packages are looking for funding
08:19:55.595  	  run `npm fund` for details
08:19:55.653  	Running "npm run vercel-build"
08:19:56.011  	> npm i -g node-gyp sharp
08:20:05.099  	npm ERR! code 1
08:20:05.099  	npm ERR! path /node12/lib/node_modules/sharp
08:20:05.101  	npm ERR! command failed
08:20:05.102  	npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
08:20:05.102  	npm ERR! sharp: Using cached /vercel/.npm/_libvips/libvips-8.11.3-linux-x64.tar.br
08:20:05.102  	npm ERR! make: Entering directory `/node12/lib/node_modules/sharp/build'
08:20:05.102  	npm ERR!   TOUCH Release/obj.target/libvips-cpp.stamp
08:20:05.102  	npm ERR!   CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
08:20:05.102  	npm ERR!   AR(target) Release/obj.target/node_modules/node-addon-api/nothing.a
08:20:05.103  	npm ERR!   COPY Release/nothing.a
08:20:05.103  	npm ERR!   CXX(target) Release/obj.target/sharp-linux-x64/src/common.o
08:20:05.103  	npm ERR! make: Leaving directory `/node12/lib/node_modules/sharp/build'
08:20:05.103  	npm ERR! prebuild-install WARN install EACCES: permission denied, access '/vercel/.npm'
08:20:05.103  	npm ERR! gyp info it worked if it ends with ok
08:20:05.103  	npm ERR! gyp info using [email protected]
08:20:05.103  	npm ERR! gyp info using [email protected] | linux | x64
08:20:05.103  	npm ERR! gyp info find Python using Python version 3.6.10 found at "/usr/local/bin/python3"
08:20:05.104  	npm ERR! gyp WARN EACCES current user does not have permission to access the dev dir "/vercel/.cache/node-gyp/12.22.6"
08:20:05.104  	npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
08:20:05.104  	npm ERR! gyp http GET https://nodejs.org/download/release/v12.22.6/node-v12.22.6-headers.tar.gz
08:20:05.104  	npm ERR! gyp http 200 https://nodejs.org/download/release/v12.22.6/node-v12.22.6-headers.tar.gz
08:20:05.104  	npm ERR! gyp http GET https://nodejs.org/download/release/v12.22.6/SHASUMS256.txt
08:20:05.104  	npm ERR! gyp http 200 https://nodejs.org/download/release/v12.22.6/SHASUMS256.txt
08:20:05.105  	npm ERR! gyp info spawn /usr/local/bin/python3
08:20:05.105  	npm ERR! gyp info spawn args [
08:20:05.105  	npm ERR! gyp info spawn args   '/node16/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
08:20:05.105  	npm ERR! gyp info spawn args   'binding.gyp',
08:20:05.105  	npm ERR! gyp info spawn args   '-f',
08:20:05.105  	npm ERR! gyp info spawn args   'make',
08:20:05.105  	npm ERR! gyp info spawn args   '-I',
08:20:05.105  	npm ERR! gyp info spawn args   '/node12/lib/node_modules/sharp/build/config.gypi',
08:20:05.105  	npm ERR! gyp info spawn args   '-I',
08:20:05.105  	npm ERR! gyp info spawn args   '/node16/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
08:20:05.105  	npm ERR! gyp info spawn args   '-I',
08:20:05.106  	npm ERR! gyp info spawn args   '/tmp/.node-gyp/12.22.6/include/node/common.gypi',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dvisibility=default',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dnode_root_dir=/tmp/.node-gyp/12.22.6',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/node16/lib/node_modules/npm/node_modules/node-gyp',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dnode_lib_file=/tmp/.node-gyp/12.22.6/<(target_arch)/node.lib',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dmodule_root_dir=/node12/lib/node_modules/sharp',
08:20:05.106  	npm ERR! gyp info spawn args   '-Dnode_engine=v8',
08:20:05.106  	npm ERR! gyp info spawn args   '--depth=.',
08:20:05.106  	npm ERR! gyp info spawn args   '--no-parallel',
08:20:05.106  	npm ERR! gyp info spawn args   '--generator-output',
08:20:05.106  	npm ERR! gyp info spawn args   'build',
08:20:05.107  	npm ERR! gyp info spawn args   '-Goutput_dir=.'
08:20:05.107  	npm ERR! gyp info spawn args ]
08:20:05.107  	npm ERR! gyp info spawn make
08:20:05.107  	npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
08:20:05.107  	npm ERR! ../src/common.cc:24:10: fatal error: vips/vips8: No such file or directory
08:20:05.107  	npm ERR!  #include <vips/vips8>
08:20:05.107  	npm ERR!           ^~~~~~~~~~~~
08:20:05.107  	npm ERR! compilation terminated.
08:20:05.108  	npm ERR! make: *** [Release/obj.target/sharp-linux-x64/src/common.o] Error 1
08:20:05.108  	npm ERR! gyp ERR! build error 
08:20:05.108  	npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
08:20:05.108  	npm ERR! gyp ERR! stack     at ChildProcess.onExit (/node16/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
08:20:05.108  	npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
08:20:05.108  	npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
08:20:05.108  	npm ERR! gyp ERR! System Linux 4.14.243-185.433.amzn2.x86_64
08:20:05.108  	npm ERR! gyp ERR! command "/node12/bin/node" "/node16/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
08:20:05.108  	npm ERR! gyp ERR! cwd /node12/lib/node_modules/sharp
08:20:05.108  	npm ERR! gyp ERR! node -v v12.22.6
08:20:05.108  	npm ERR! gyp ERR! node-gyp -v v7.1.2
08:20:05.109  	npm ERR! gyp ERR! not ok
08:20:05.128  	npm ERR! A complete log of this run can be found in:
08:20:05.129  	npm ERR!     /vercel/.npm/_logs/2021-09-29T05_20_05_110Z-debug.log
08:20:05.154  	Error: Command "npm run vercel-build" exited with 1

my vercel.json is:

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "@vercel/node"
    },
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["./.nuxt/dist/sitemap-routes.json"],
        "generateStaticRoutes": true
      }
    }
  ],
  "headers": [
    {
      "source": "/news(.*)",
      "headers": [
        {
          "key": "Cache-Control",
          "value": "s-maxage=43200, stale-while-revalidate"
        }
      ]
    }
  ]
}

my package.json has also this script:

"vercel-build": "npm i -g node-gyp sharp"

treboryx avatar Sep 29 '21 05:09 treboryx

I setup a fresh nuxt project with create-nuxt-app, added the same configuration (vercel-build script & vercel.json), it builds just fine, I have no idea why because it's the same config, HOWEVER, it doesn't work

image (target: static)

It's pointing to the wrong directory maybe?

In both cases I should mention that everything works fine in local env.

treboryx avatar Sep 29 '21 18:09 treboryx

I'm having the same issue. Have you found any solution yet? Edit: created new issue https://github.com/nuxt/image/issues/434

riccardolardi avatar Oct 06 '21 13:10 riccardolardi

I'm having the same issue. Have you found any solution yet?

Unfortunately not, just waiting for anyone who knows what's up to take a look.

treboryx avatar Oct 06 '21 13:10 treboryx

Same issue here as well

ryanwolhuter avatar Oct 07 '21 07:10 ryanwolhuter

As pointed out in https://github.com/nuxt/image/issues/434 I got it to build by overriding Vercel's install command with SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm_config_arch=x64 npm_config_platform=linux yarn add sharp && yarn install but now the images all error out with 404

riccardolardi avatar Oct 11 '21 07:10 riccardolardi

Just to add a +1, getting the same here

Jamiewarb avatar Oct 27 '21 10:10 Jamiewarb

+1

SushyDev avatar Jun 11 '22 17:06 SushyDev