Heroku 64-bit Ubuntu 14.04 + yarn: Cannot find module '../build/Release/sharp.node'
See original GitHub issueWhen attempting to build a project on heroku we are experiencing an issue where sharp.node is not being found. Below is the heroku build output:
Downloading and installing node 6.9.1...
Using default npm version: 3.10.8
Downloading and installing yarn (0.20.3)...
Installed yarn 0.20.3
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (yarn.lock)
yarn install v0.20.3
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.0.17: The platform "linux" is incompatible with this module.
info "fsevents@1.0.17" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "redux-form@5.2.5" has incorrect peer dependency "react-redux@^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
$ gulp build
module.js:471
throw err;
^
Error: Cannot find module '../build/Release/sharp.node'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/tmp/build_a0cdb656013074c78176c1bdebea3455/Lostmyname-website-d9b76f1e1644504c47a0c934bed5fd92db728cb1/node_modules/sharp/lib/constructor.js:8:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Heroku + Node: Cannot find module error - Stack Overflow
The solution was to rename User.js and Company.js on my local system to new temporary files, commit the changes to git, then rename...
Read more >Why is my Node.js build failing because of no matching Yarn ...
Heroku recommends specifying the exact version of Yarn that you are using locally in the engines field. To find your version locally:
Read more >how to install express in console Code Example
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). ... E: The repository 'http://ppa.launchpad.net/certbot/certbot/ ...
Read more >Docker with Strapi V4 - Adventures of Eventyret
Docker; NPM / Yarn (Yarn is recommended); Node 14 is recommended but 16 will work if ... So all that is missing is...
Read more >Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
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
We were experiencing this issue, and got things working again by setting
NODE_MODULES_CACHE
tofalse
(heroku -a <appname> config:set NODE_MODULES_CACHE=false
).Our best guess, based on some rudimentary testing, is that heroku is not able or not configured to cache binary files. So if caching is enabled, an initial deploy works fine, but a second deploy will attempt to use the cached modules, which do not contain the necessary binary files. Disabling caching forces the application to always use the correct, uncached
node_modules
directory.Docs updated in 5e015cc, thanks all.