opennextjs-netlify: [Bug]: Loading images via ipx doesn't work
Summary
The issue appeared from nowhere I just merged my dev branch to master and after the deployment, I see this error I tried to redeploy many times but no luck The interesting thing the previous build had this version of the plugin and it works somehow.
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'ipx'\nRequire stack:\n- /var/task/node_modules/@netlify/ipx/dist/index.js\n- /var/task/.netlify/functions-internal/_ipx/_ipx.js\n- /var/task/_ipx.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'ipx'",
"Require stack:",
"- /var/task/node_modules/@netlify/ipx/dist/index.js",
"- /var/task/.netlify/functions-internal/_ipx/_ipx.js",
"- /var/task/_ipx.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:202:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
" at internal/main/run_main_module.js:17:47"
]
}```
### Steps to reproduce
1.
### A link to a reproduction repository
_No response_
### Plugin version
4.2.6
### More information about your build
- [ ] I am building using the CLI
- [ ] I am building using file-based configuration (`netlify.toml`)
### What OS are you using?
_No response_
### Your netlify.toml file
<details>
<summary>`netlify.toml`</summary>
```toml
# Paste content of your `netlify.toml` file here
Your public/_redirects file
`_redirects`
# Paste content of your `_redirects` file here
Your next.config.js file
`next.config.js`
/** eslint-disable @typescript-eslint/no-var-requires */
const withTM = require("next-transpile-modules")([
"@solana/wallet-adapter-base",
"@solana/wallet-adapter-react",
"@solana/wallet-adapter-phantom",
]);
/** @type {import('next').NextConfig} */
module.exports = withTM({
reactStrictMode: true,
webpack5: true,
images: {
domains: ["www.arweave.net", "dl.airtable.com"],
},
});
Builds logs (or link to your logs)
Build logs
# Paste logs here
Function logs
Function logs
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'ipx'\nRequire stack:\n- /var/task/node_modules/@netlify/ipx/dist/index.js\n- /var/task/.netlify/functions-internal/_ipx/_ipx.js\n- /var/task/_ipx.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'ipx'",
"Require stack:",
"- /var/task/node_modules/@netlify/ipx/dist/index.js",
"- /var/task/.netlify/functions-internal/_ipx/_ipx.js",
"- /var/task/_ipx.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:202:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
" at internal/main/run_main_module.js:17:47"
]
.next JSON files
generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17 (6 by maintainers)
Hey @ascorbic, I’ve been running into this issue as well on a NextJS site I’ve been trying to deploy to Netlify today.
I’ve gone ahead and created a minimal public repo that reproduces this problem when deployed to Netlify. You should be able to see the 502 of the images failing to be generated in the console.
Repo: https://github.com/asyarb/ipx-netlify-repro Netlify Deployment: https://ipx-repro.netlify.app/ IPX Function Reproduction: https://ipx-repro.netlify.app/_ipx/w_3840,q_75/%2F_next%2Fstatic%2Fmedia%2Fsample.615160ff.jpg?url=%2F_next%2Fstatic%2Fmedia%2Fsample.615160ff.jpg&w=3840&q=75
Hopefully this is helpful!
For anyone still experiencing the problem after running
npm update ipxremember to clear the deploy cache and redeploy.Thanks everyone for your help! We tracked it down to a bug in the latest version of ipx. They’ve pushed a fix, and I’ve confirmed that fixes the issue. Run
npm update ipxand it should update it to 0.9.4 (runnpm ls ipxto check). I’m closing this now, but do please confirm whether this fixes it for you.Thanks @asyarb! I’ll get onto that today
Hi @kurpav, I believed the same thing but later realized ipx is installed as a dependency of the netlify plugin so it still appears in the
package-lock.jsonfile but not in thepackage.jsonfile. You still need to runnpm update ipxto update thepackage-lock.jsonfile and then redeploy.Yes, to be clear: running
npm updatewill just upgrade the version in your lockfiles, which you then need to push as an update. If you haven’t manually installed the plugin, you don;t need to do this: just upgrade the plugin via the site UI.Confirming that image optimization is working for me now. Thank you for your help!