What are you trying to achieve?
Sharp is a dependency in a gatsby project I'm working on. Whenever I run any gatsby commands, I get the following error:
The module '<sharp module path>'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
- Ensure the version of Node.js used at install time matches that used at runtime
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues
I've run both npm rebuild and npm install and neither fix the issue.
Have you searched for similar questions?
I noticed that issue 1689 was similar, however, I'm not using electron.
Node 12 was used at npm install time but Node 10 is being used at runtime.
The NODE_MODULE_VERSION is a bit confusing as it represents an internal ABI version number. You can see what external version number these relate to at https://nodejs.org/en/download/releases/
That's the thing, I don't have node 12 on my machine, I previously had node 9.x.x & upgraded to 10.x.x. Would you recommend me installing 12?
Oh, that's interesting, could the files in node_modules have been copied from another machine?
What's the output of running npm install --verbose sharp?
They were actually, I used a starter theme for the Gatsby project, I guess that could be it. When I run that command, I get an error lol
TypeError: Cannot read property 'match' of undefined
It's usually best to avoid copying node_modules between machines. You can safely delete it and re-create it for your OS and (major) version of Node via npm install.
I get this exact same issue too. I've tried completely removing, unlinking and pruning node and npm and re-installing, deleting node_modules folder. npm installing and npm uninstalling sharp, npm rebuilding. really not sure what's going on but it means i can't compile and run my gatsby site :(
node -v
v12.4.0
npm -v
6.9.0
Something went wrong installing the "sharp" module
The module '/node_modules/sharp/build/Release/sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 67. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
@fortydegrees That error means that npm install was run using Node 11. There are probably multiple, conflicting versions of Node on your machine.
So I completely nuked node_modules & the package-lock.json but no success unfortunately :( still the same error.
@lolaodelola When you say "same error", does this refer to "TypeError: Cannot read property 'match' of undefined"? If so, perhaps there's a npm-shrinkwrap.json file that also needs removing?
Yeah, I've completely removed node and npm from my system multiple times and don't have any other versions installed, and still get this error
I notice that when i run a clean 'npm i' which the latest node installed and no others, this command gets run:
[email protected] preinstall /Users/david/ballpark/website/node_modules/node
node installArchSpecificPackage
I assume it's the [email protected] that's causing the error.
I downgraded node v12.4.0 to node@10 via brew, but this still didn't work:
The module '/node_modules/sharp/build/Release/sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 67. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
is there any reason why 'npm install' is compiling this with a specific version of node? i only have one version installed, and have tried changing from 12 to 10.
I got round this error by installing NVM and specifically installing node 11.15.0, removing all instances of node and node_modules and package-lock.json.
however, i now get a new error which is discussed here: https://github.com/gatsbyjs/gatsby/issues/13278
clearly not an issue with sharp - although I still don't understand exactly what it is and even how it happened.. and I still haven't fixed it, but feel like this isn't the place for this error and seems to be something to do with npm installing modules in different orders?
FWIW, I've fixed this, just about.. Still not sure what the problem was and really don't think it's anything to do with sharp but here's what I'd recommend:
completely uninstall and remove all instances of node, npm. node_modules and package-lock
install nvm and install node version v11.15.0
run npm i and see if that works
if you get the graphQL error, delete node modules and package-lock again
run npm i again, then it should work - at least it did for me
Had the same problem but for a global package. The problem was I compiled Sharp with node 9.x.x and after that, I needed to install node 10.x.x for the package that I use. That made the conflict, and the solution was to recompile sharp with node 10.x.x and the error was gone.
How did you recompile sharp with a specific node version? I tried npm rebuild sharp node v10.15.3 but that didn't help so I don't think I am running the correct command. I get the below ouput.
Something went wrong installing the "sharp" module
The module '/Users/susanabenavidez/.npm-global/lib/node_modules/expo-cli/node_modules/sharp/build/Release/sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 67. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
i installed nvm, used that to install the specific node version, then
removed node_modules and package-lock.json and ran npm install
On Mon, 17 Jun 2019 at 16:53, Susana LaCoder Benavidez <
[email protected]> wrote:
How did you recompile sharp with a specific node version? I tried npm
rebuild sharp node v10.15.3 but that didn't help so I don't think I am
running the correct command. I get the below ouput.Something went wrong installing the "sharp" module
The module
'/Users/susanabenavidez/.npm-global/lib/node_modules/expo-cli/node_modules/sharp/build/Release/sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 67. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
- Ensure the version of Node.js used at install time matches that used
at runtime- Consult the installation documentation at
https://sharp.pixelplumbing.com/en/stable/install/- Search for this error at https://github.com/lovell/sharp/issues
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about
this command.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/lovell/sharp/issues/1746?email_source=notifications&email_token=AJFN4HN6EYJ7IJXE77CSEY3P26XPDA5CNFSM4HVYPBR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX3TVYQ#issuecomment-502741730,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJFN4HO3ZCFIARPAKXOQRMLP26XPDANCNFSM4HVYPBRQ
.
@LACoderDeBH For expo-cli, please see https://github.com/expo/expo-cli/issues/591#issuecomment-491236180
rm -rf node_modules to remove the old installation of sharpnpm install worked :):wave: cheers
@lolaodelola I hope you were able to solve your original problem, please feel free to re-open with more details if not.
Thanks everyone else for the hints and tips!
What are you trying to achieve?
Sharp is a dependency in a gatsby project I'm working on. Whenever I run any gatsby commands, I get the following error:The module '<sharp module path>' was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js requires NODE_MODULE_VERSION 64. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`). - Ensure the version of Node.js used at install time matches that used at runtime - Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/ - Search for this error at https://github.com/lovell/sharp/issuesI've run both
npm rebuildandnpm installand neither fix the issue.Have you searched for similar questions?
I noticed that issue 1689 was similar, however, I'm not using electron.
Thank you so much! Your question give me such good solution.
Just run: 'npm rebuild'. Done for me :D hehe
Node 12 bad. Node 10 good.
Most helpful comment
@LACoderDeBH For expo-cli, please see https://github.com/expo/expo-cli/issues/591#issuecomment-491236180