-
Notifications
You must be signed in to change notification settings - Fork 27.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Cannot find module when deploying to heroku #198
Comments
What does your package.json look like? Did it ever work on Heroku, or just this version? |
Exactly as in readme. First time tried it on heroku. On 5 Nov 2016, 19:39 +0200, Eric Zingeler notifications@github.com, wrote:
|
Maybe devDependencies is needed. Heroku by default only installs dependencies when deploying. Give this a go: |
@eezing I have only one dependency, |
Is the 'next build' command happening before 'next start'? |
Hello, I have exactly the same issue:
I followed your advice @eezing and I forced the install of the devDependencies with: I checked: the And like @nvartolomei I only have Anyone running on Heroku successfully? |
@eezing unfortunately I don't have time at the moment to dig into this. |
Same problem here:
|
next.js transforms some |
This appears other places (like a Flynn cluster) which use the Heroku buildpacks:
|
Is there a verbose option on |
I can confirm via downloading a Flynn slug (which uses Heroku buildpacks) that I'll take a crack at solving this via PR... it will likely require the use of relative paths all over the place re: flynn/flynn#3696 |
I can confirm that both on Flynn and Heroku the |
For heroku/dokku you might use "scripts": {
"prestart": "next build",
"start": "next start -p ${PORT}",
} |
Yes @dotcypress, adding a prestart step solved my issue. Thanks |
This is related to the common babel-runtime error. Asking user to provide to If we are not going to turn off helpers, we may could do some Webpack's require.resolve magic to get around with this. |
The A: Not use absolute paths when compiling |
Another way to resolve modules from // before
const foo = require('babel-runtime/foo')
// after
const foo = require('next/require')('babel-runtime/foo')
export default (moduleId) => require(moduleId) Though we'd need a workaround for the webpack compilation since dynamic |
BTW: Sad, but this is blocker for our project, how can i help with fix? |
@dotcypress how about using some buildpacks. With that, you could run a bash script when building the heroku slug. |
@arunoda but how this will help with Dokku Zero Downtime Deploys? |
I assume, Dokku uses buildpacks behind the scene. |
The problem of zero downtime deployment is completely unrelated to Next.js. So is building. Our focus is to provide a simple way to build. Just like you develop with This is already documented here: https://github.com/zeit/next.js#production-deployment With now, we take care of zero downtime by having you deploy, and then use |
Just got through this today. There were two parts to getting it working.
I didn't move:
|
Tried this today. As for @KidkArolis, my solution was adding a
as well as
As you can see, no further changes to |
@tomsoderlund, does that mean that every time you restart your dyno it does a build? |
You no longer need the buildpack or a custom procfile (next v2+) for Heroku. www.actionherojs.com is a Next project, and its full source is here https://github.com/actionhero/www.actionherojs.com. Just include the following in your
|
@evantahler this is great news! 💯 |
@jcheroske I'm not 100% sure, but based on the time required to restart vs. when building (I can see when |
Hi, I deleted a load of files and I'm getting this error on pushing to Heroku. It seems like a previous build is looking for one of those files? I don't understand why this is happening and where did I go wrong. I have faced this problem one time before, but apparently, it fixed itself then.
It then tries to find the file in multiple directories, using multiple file extensions. It doesn't exist anymore. I have tried to use Using |
When I run 'npm run build' and 'npm run start' locally everything works. When I push to Heroku I get:
It was working fine earlier on heroku, and I did some updates to my server.js script related to 'connect-redis' session functions, and now the above happens. |
And when I purge the cache from my Heroku instance, there error looks like:
|
@paulwehner looks weird, what happens if you regenerate |
I had problems with Heroku not finding NPM's after upgrading from Next.js 3 beta to 3.2.2, but disabling Heroku's caching of Node modules solved it:
|
Source if the issues is Heroku production DOES NOT install devDependecies. So move to dependencies all build modules you need. Just ugly but Heroku works that way... |
A few things worth checking, some noted here already:
|
Here's another hilarious solution if you're still having trouble. Create a prestart script which builds the ./prestart.js
./package.json Assumes you're using a custom server.js file. If not, just run
|
Looks like this issue is more closer to #3533I'm on next 5, getting the same issue on heroku A snippet of the error on heroku after deploy
|
@craigcartmell it worked just fine for me. I know it doesnt seems to be the "best" solution, but as a quick fix, it fits perfectly. thank you. |
@dotcypress 's solution above allowed me to finally at least load my home page... but if I go to any other route than '/', I get this error. It seems I can load the files fine, but I get a 500 error on the route? |
Yeah this definitely still exist in next 5, or maybe re-appeared, whatever. The issue should be re-opened. I'm transpiling typescript, but doesn't matter if I use
Fixed it! I just added |
My app deploys fine using next@4. Upgrading to next@5 I get the |
Upgrade to |
Hello everyone, 2018-08-02T11:37:50.384799+00:00 heroku[web.1]: Starting process with command |
1 similar comment
Hello everyone, 2018-08-02T11:37:50.384799+00:00 heroku[web.1]: Starting process with command |
Im having same problem of all of you. Local it works, but while in heroku or NOW , has same errors. How to fix it? Or where can I deploy it? |
Hey all, Looks like the same issue is happening with Next v8. Here's what I have setup.
I've tried a few methods to get the build to run as expected.
No matter what I do - here's the log I get minus expected differences from the different methods.
Any thoughts? |
This was the only one that actually worked for me.
Cheers |
Using latest next.js relase and a simple hello world index page with 0 dependencies fails to run on heroku with the following error:
The text was updated successfully, but these errors were encountered: