Sharp module error while deploying to heroku

-----> Building on the Heroku-18 stack

-----> Using buildpack: heroku/nodejs

-----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_ENV=production
   NODE_MODULES_CACHE=true
   NODE_VERBOSE=false

-----> Installing binaries

   engines.node (package.json):  >=10.0.0
   engines.npm (package.json):   >=6.0.0
   
   Resolving node version >=10.0.0...
   Downloading and installing node 16.1.0...
   Bootstrapping npm >=6.0.0 (replacing 7.11.2)...
   npm >=6.0.0 installed

-----> Restoring cache

   Cached directories were not restored due to a change in version of node, npm, yarn or stack
   Module installation may take longer for this build

-----> Installing dependencies

   Installing node modules
   npm ERR! code 1
   npm ERR! path /tmp/build_95faedf4/node_modules/sharp
   npm ERR! command failed
   npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
   npm ERR! make: Entering directory '/tmp/build_95faedf4/node_modules/sharp/build'
   npm ERR!   TOUCH Release/obj.target/libvips-cpp.stamp
   npm ERR!   CXX(target) Release/obj.target/sharp/src/common.o
   npm ERR! sharp.target.mk:139: recipe for target 'Release/obj.target/sharp/src/common.o' failed
   npm ERR! make: Leaving directory '/tmp/build_95faedf4/node_modules/sharp/build'
   npm ERR! info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.0/libvips-8.9.0-linux-x64.tar.gz
   npm ERR! gyp info it worked if it ends with ok
   npm ERR! gyp info using node-gyp@7.1.2
   npm ERR! gyp info using node@16.1.0 | linux | x64
   npm ERR! gyp info find Python using Python version 3.6.9 found at "/usr/bin/python3"
   npm ERR! gyp http GET https://nodejs.org/download/release/v16.1.0/node-v16.1.0-headers.tar.gz
   npm ERR! gyp http 200 https://nodejs.org/download/release/v16.1.0/node-v16.1.0-headers.tar.gz
   npm ERR! gyp http GET https://nodejs.org/download/release/v16.1.0/SHASUMS256.txt
   npm ERR! gyp http 200 https://nodejs.org/download/release/v16.1.0/SHASUMS256.txt
   npm ERR! (node:2077) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
   npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
   npm ERR! gyp info spawn /usr/bin/python3
   npm ERR! gyp info spawn args [
   npm ERR! gyp info spawn args   '/tmp/build_95faedf4/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
   npm ERR! gyp info spawn args   'binding.gyp',
   npm ERR! gyp info spawn args   '-f',
   npm ERR! gyp info spawn args   'make',
   npm ERR! gyp info spawn args   '-I',
   npm ERR! gyp info spawn args   '/tmp/build_95faedf4/node_modules/sharp/build/config.gypi',
   npm ERR! gyp info spawn args   '-I',
   npm ERR! gyp info spawn args   '/tmp/build_95faedf4/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
   npm ERR! gyp info spawn args   '-I',
   npm ERR! gyp info spawn args   '/app/.cache/node-gyp/16.1.0/include/node/common.gypi',
   npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
   npm ERR! gyp info spawn args   '-Dvisibility=default',
   npm ERR! gyp info spawn args   '-Dnode_root_dir=/app/.cache/node-gyp/16.1.0',
   npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/tmp/build_95faedf4/.heroku/node/lib/node_modules/npm/node_modules/node-gyp',
   npm ERR! gyp info spawn args   '-Dnode_lib_file=/app/.cache/node-gyp/16.1.0/<(target_arch)/node.lib',
   npm ERR! gyp info spawn args   '-Dmodule_root_dir=/tmp/build_95faedf4/node_modules/sharp',
   npm ERR! gyp info spawn args   '-Dnode_engine=v8',
   npm ERR! gyp info spawn args   '--depth=.',
   npm ERR! gyp info spawn args   '--no-parallel',
   npm ERR! gyp info spawn args   '--generator-output',
   npm ERR! gyp info spawn args   'build',
   npm ERR! gyp info spawn args   '-Goutput_dir=.'
   npm ERR! gyp info spawn args ]
   npm ERR! gyp info spawn make
   npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
   npm ERR! <command-line>:0:0: warning: "_GLIBCXX_USE_CXX11_ABI" redefined
   npm ERR! <command-line>:0:0: note: this is the location of the previous definition
   npm ERR! In file included from /app/.cache/node-gyp/16.1.0/include/node/v8.h:30:0,
   npm ERR!                  from /app/.cache/node-gyp/16.1.0/include/node/node.h:63,
   npm ERR!                  from ../src/common.cc:22:
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’
   npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
   npm ERR!                                       ^~~~~~~~~~~
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:38: note: suggested alternative: ‘remove_cv’
   npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
   npm ERR!                                       ^~~~~~~~~~~
   npm ERR!                                       remove_cv
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:38: note: suggested alternative: ‘remove_cv’
   npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
   npm ERR!                                       ^~~~~~~~~~~
   npm ERR!                                       remove_cv
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:50: error: template argument 2 is invalid
   npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
   npm ERR!                                                   ^
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:63: error: ‘::Perform’ has not been declared
   npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
   npm ERR!                                                                ^~~~~~~
   npm ERR! /app/.cache/node-gyp/16.1.0/include/node/v8-internal.h:452:63: note: suggested alternative: ‘perror’
   npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
   npm ERR!                                                                ^~~~~~~
   npm ERR!                                                                perror
   npm ERR! At global scope:
   npm ERR! cc1plus: warning: unrecognized command line option ‘-Wno-cast-function-type’
   npm ERR! make: *** [Release/obj.target/sharp/src/common.o] Error 1
   npm ERR! gyp ERR! build error 
   npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
   npm ERR! gyp ERR! stack     at ChildProcess.onExit (/tmp/build_95faedf4/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
   npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
   npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
   npm ERR! gyp ERR! System Linux 4.4.0-1088-aws
   npm ERR! gyp ERR! command "/tmp/build_95faedf4/.heroku/node/bin/node" "/tmp/build_95faedf4/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
   npm ERR! gyp ERR! cwd /tmp/build_95faedf4/node_modules/sharp
   npm ERR! gyp ERR! node -v v16.1.0
   npm ERR! gyp ERR! node-gyp -v v7.1.2
   npm ERR! gyp ERR! not ok
   npm ERR! A complete log of this run can be found in:
   npm ERR!     /tmp/npmcache.w5d5j/_logs/2021-05-05T10_10_30_656Z-debug.log

-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys
   
   Some possible problems:
   
   - Dangerous semver range (>) in engines.node
     https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
   
   Love,
   Heroku

! Push rejected, failed to compile Node.js app.
! Push failed

modify the version of node and npm
“engines”: {
“node”: “14.x”,
“npm”: “6.x”
},