next.js: Can no longer build with `9.3.4`
Bug report
Describe the bug
After upgrading to 9.3.4, next build errors with:
❯ npm run build
> my-project@1.0.0 build /dev/my-project
> cross-env NEXT_TELEMETRY_DISABLED=1 next build
Creating an optimized production build
Failed to compile.
./node_modules/next/dist/client/next.js
TypeError: invalid options argument
at new Promise (<anonymous>)
at Generator.throw (<anonymous>)
> Build error occurred
Error: > Build failed because of webpack errors
at build (/dev/my-project/node_modules/next/dist/build/index.js:13:900)
I noticed that, for some reason, the actual line in which the error is thrown varies between runs of next build, seemingly at random. However, the error message is always the same.
For example:
Failed to compile.
./node_modules/next/dist/client/polyfills.js
TypeError: invalid options argument
Failed to compile.
./node_modules/next/dist/client/router.js
TypeError: invalid options argument
Expected behavior
Project builds correctly.
System information
- OS: macOS Catalina 10.15.4 (19E266)
- Version of Next.js:
9.3.4 - Version of node:
v12.16.1
Additional context
No other modifications were done or applied. All other dependencies remain the same in lockfile.
Reverting back to 9.3.3 solves the issue for me.
❯ npm remove next && npm i next@9.3.3
+ next@9.3.3
added 656 packages from 270 contributors and audited 1063442 packages in 27.174s
77 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
❯ npm run build
> my-project@1.0.0 build /dev/my-project
> cross-env NEXT_TELEMETRY_DISABLED=1 next build
Creating an optimized production build
Compiled successfully.
Automatically optimizing pages
# ...
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 17
- Comments: 43 (18 by maintainers)
@timneutkens I believe I tracked down the issue to the
mkdirpdependency. Specifically, how npm’s registry resolves themkdirpdependency to this repo, while the yarn registry resolvesmkdirpdependency to this repo. Swapping out the npm registry version (v1.0.3) for the yarn locked registry version (v0.5.4) seems to have fixed the issue.Perhaps providing a
package.lock.jsonin addition to theyarn.lockmay solve this problem or perhaps addingmkdirp@0.5.4to next’s package.jsondevDependencies. Let me know how you wish to proceed. I can create a pull request if needed.Working example (use
npm ioryarn, both should compile without errors): https://github.com/mattcarlotta/next-9.3.4-reproductionIt appears, in andrew’s case, that the
apollopackage requiresmkdir: "^1.0.3", while every other package, requiresmkdirp "^0.5.0":I do face the same problem with 9.3.4 but with different error message, see below. Version 9.3.3 do me just fine.
^ This part precisely same as @howks @nfantone problem above
Figured out what’s going on, sending a PR to fix
Don’t know why but
package-lock.json,node_modules,npm installseems fix the thing. I successfully run
next buildafter that.One thing that you could potentially do is this: https://github.com/zeit/next.js/issues/11583#issuecomment-607825557
That would clean up your node_modules which could be in a bad state (because of that issue with the npm cli).
I’m not sure why none of these comments provide a complete reproduction which makes it impossible for us to help you / investigate the issue. If you do provide a complete reproduction we can more easily tell you what the problem is.
I’d be super happy to investigate deeper.
https://github.com/andrewl913/next-9.3.4-reproduction here is a reproduction. Not tracking package.lock.json.
Edit: Some further insight, this could related to the intergration with Apollo.
Hi, I also have error after upgrading to 9.3.4
On version 9.3.3 everything works
That’s what I meant. Reworded my comment a bit.
Here is what I did… When installing next there was a warning :
npm WARN deprecated mkdirp@0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
It was about promises…hmmm ok… It wanted me to upgrade to next9.3.4 to fix this when running npm audit.
I tried to update the mkdirp package but got the same error on running next dev.
I uninstall next and rolled back my next version to @9.3.1
next dev compiled…
@nfantone if you have a chance, clone my repo and see if you still see the issue.
@andrewl913 FWIW, I’m not using GraphQL at all.
I can confirm this is an issue. Wonder how this could get through CI / CD.
This happens with
next devas well