Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Cannot find module 'jimp' #143

Closed
ctsimpouris opened this issue Jan 16, 2021 · 12 comments · Fixed by #158
Closed

Cannot find module 'jimp' #143

ctsimpouris opened this issue Jan 16, 2021 · 12 comments · Fixed by #158
Labels
priority: high type: bug code to address defects in shipped code

Comments

@ctsimpouris
Copy link

Describe the bug
Unfortunately no repo can be provided

Versions
Bug started to appear on Wednesday, 13/1/2021 after this commit.

Log
After this commit, the same code stopped being able to be deployed to Netlify with the following log

12:41:02 AM: ────────────────────────────────────────────────────────────────
12:41:02 AM:   4. Functions bundling                                         
12:41:02 AM: ────────────────────────────────────────────────────────────────
12:41:02 AM: ​
12:41:02 AM: Packaging Functions from out_functions directory:
12:41:02 AM:  - next_categories/next_categories.js
12:41:02 AM:  - next_collections/next_collections.js
12:41:02 AM:  - next_image.js
12:41:02 AM:  - next_index/next_index.js
12:41:02 AM:  - next_vid_name_term_id/next_vid_name_term_id.js
12:41:13 AM: ​
12:41:13 AM: ────────────────────────────────────────────────────────────────
12:41:13 AM:   Dependencies installation error                               
12:41:13 AM: ────────────────────────────────────────────────────────────────
12:41:13 AM: ​
12:41:13 AM:   Error message
12:41:13 AM:   A Netlify Function failed to require one of its dependencies.
12:41:13 AM:   If the dependency is a Node module, please make sure it is present in the site's top-level "package.json".
  If it is a local file instead, please make sure the file exists and its filename is correctly spelled.
12:41:13 AM: ​
12:41:13 AM:   In file "/opt/build/repo/frontend/sfx-next/out_functions/next_image.js"
12:41:13 AM:   Cannot find module 'jimp'
12:41:13 AM:   Require stack:
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/main.js
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/commands/get.js
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js
12:41:13 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js

while also function next_image.js started to appear out of the blue. Due to Cannot find module 'jimp', I proceed and installed dependency jimp, making the deployment process work as expected. However, this is something that definitely within my repo is not used so far.

@lindsaylevine
Copy link
Contributor

hey @ctsimpouris ! apologies about this. yes, jimp is required for our next/image support, but no, you shouldn't have to install it yourself. can you do me a favor and try using https://github.com/netlify/netlify-plugin-nextjs instead of the standard next-on-netlify configuration you're using? if you do try it, make sure you uninstall jimp before re-attempting a build/deploy.

@gregg-cbs
Copy link

gregg-cbs commented Jan 17, 2021

I am receiving the same issue even with your suggestion.
I uninstalled Netlifys plugins: Next.js Cache and Next on Netlify.
I installed the netlify-plugin-nextjs node module as recommended in the readme in the repo and add the toml config.

I have no issues building locally.
On netlify i see the following error:

1:21:01 PM: ────────────────────────────────────────────────────────────────
1:21:01 PM:   Dependencies installation error                               
1:21:01 PM: ────────────────────────────────────────────────────────────────
1:21:01 PM: ​
1:21:01 PM:   Error message
1:21:01 PM:   A Netlify Function failed to require one of its dependencies.
1:21:01 PM:   If the dependency is a Node module, please make sure it is present in the site's top-level "package.json".
  If it is a local file instead, please make sure the file exists and its filename is correctly spelled.
1:21:01 PM: ​
1:21:01 PM:   In file "/opt/build/repo/netlify-automatic-functions/next_country_area_companyId/next_country_area_companyId.js"
1:21:01 PM:   Cannot find module 'critters'
1:21:01 PM:   Require stack:
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/main.js
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/commands/get.js
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js
1:21:01 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js
1:21:01 PM: ​
1:21:01 PM:   Resolved config
1:21:01 PM:   build:
1:21:01 PM:     command: npm run build
1:21:01 PM:     commandOrigin: config
1:21:01 PM:   plugins:
1:21:01 PM:     - inputs: {}
1:21:01 PM:       origin: config
1:21:01 PM:       package: '@netlify/plugin-nextjs'

@gregg-cbs
Copy link

Installing critter as a dev dependancy has fixed the issue and my site loads fine.

Thank you!

@lindsaylevine
Copy link
Contributor

lindsaylevine commented Jan 17, 2021

hey @gregg-cbs! critters is a separate issue from jimp, believe it or not 😆

what next version are you using? the critters issue should be resolved now per #103 (comment)

@james-work-account
Copy link

james-work-account commented Jan 17, 2021

Hi @lindsaylevine I'm also unable to deploy due to my Netlify deployment being unable to find jimp:

3:41:09 PM: ────────────────────────────────────────────────────────────────
3:41:09 PM:   Dependencies installation error                               
3:41:09 PM: ────────────────────────────────────────────────────────────────
3:41:09 PM: ​
3:41:09 PM:   Error message
3:41:09 PM:   A Netlify Function failed to require one of its dependencies.
3:41:09 PM:   If the dependency is a Node module, please make sure it is present in the site's top-level "package.json".
  If it is a local file instead, please make sure the file exists and its filename is correctly spelled.
3:41:09 PM: ​
3:41:09 PM:   In file "/opt/build/repo/netlify-automatic-functions/next_image.js"
3:41:09 PM:   Cannot find module 'jimp'
3:41:09 PM:   Require stack:
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/main.js
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/commands/get.js
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js
3:41:09 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js
3:41:09 PM: ​
3:41:09 PM:   Resolved config
3:41:09 PM:   build:
3:41:09 PM:     command: next build
3:41:09 PM:     commandOrigin: ui
3:41:09 PM:   plugins:
3:41:09 PM:     - inputs: {}
3:41:09 PM:       origin: ui
3:41:09 PM:       package: netlify-plugin-cache-nextjs
3:41:09 PM:     - inputs: {}
3:41:09 PM:       origin: ui
3:41:09 PM:       package: '@netlify/plugin-nextjs'
3:41:09 PM: Caching artifacts
3:41:09 PM: Started saving node modules
3:41:09 PM: Finished saving node modules
3:41:09 PM: Started saving build plugins
3:41:09 PM: Finished saving build plugins
3:41:09 PM: Started saving pip cache
3:41:10 PM: Finished saving pip cache
3:41:10 PM: Started saving emacs cask dependencies
3:41:10 PM: Finished saving emacs cask dependencies
3:41:10 PM: Started saving maven dependencies
3:41:10 PM: Finished saving maven dependencies
3:41:10 PM: Started saving boot dependencies
3:41:10 PM: Finished saving boot dependencies
3:41:10 PM: Started saving rust rustup cache
3:41:10 PM: Finished saving rust rustup cache
3:41:10 PM: Started saving rust cargo bin cache
3:41:10 PM: Finished saving rust cargo bin cache
3:41:10 PM: Started saving go dependencies
3:41:10 PM: Finished saving go dependencies
3:41:12 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:41:12 PM: Failing build: Failed to build site
3:41:12 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2

This is with Next version 10.0.5 and after installing https://github.com/netlify/netlify-plugin-nextjs through the UI about 20 minutes ago.

@james-work-account
Copy link

@lindsaylevine this is a fresh site linked up to GitHub, not deployed through the CLI at all if that helps. Apart from Next version being slightly different to another site I deployed without any issues roughly a month ago (10.0.3 vs 10.0.5), I can't see any differences between the apps in terms of config/versions/deploy method etc.

@james-work-account
Copy link

Creating a netlify.toml file containing:

[build]
  command   = "npm run build"

[[plugins]]
  package = "@netlify/plugin-nextjs"

and installing @netlify/plugin-nextjs as a dev dependency does seem to have fixed this, though I'm curious why using the UI didn't work.

@lindsaylevine
Copy link
Contributor

@james-work-account hey james! so sorry about this. we're not sure why our functions bundling logic can't find jimp when it's a dependency of both the plugin and next-on-netlify. the fact that you installed the plugin as a dev dependency and it worked is good info for us; that means simply having it in the plugin on runs does not affect the bundling at all aka why the UI wouldn't work (because the one-click UI won't install it to your project). your project has to have it as a dependency or peer dependency, which shouldn't be the case.

i'll be rolling this back later, i think, instead of telling everyone to temporarily install the plugin or jimp. appreciate the patience and the helpful comments! <3

@Ali-Parandeh
Copy link

Yeah i Had the same issue and installed @netlify/plugin-nextjs then added the toml file and now it deployed successfully.

@lindsaylevine
Copy link
Contributor

hey all, just released next-on-netlify with the revert. headed to update the plugin now. won't have answers to the jimp issue til tuesday earliest. apologies once again!

@gregg-cbs
Copy link

gregg-cbs commented Jan 25, 2021

I ended up using Heroku instead for a number of reasons. Not due to this, this was easy to solve but due to other Netlify limitations. I am happy with my decision.

Thanks to the Author/Collaborator for a super quick response and action plan. Cant be easy managing side repos, life and your job. Respect.

@lindsaylevine
Copy link
Contributor

@gregg-cbs hey, thanks for your transparency! no worries at all, totally understand. would love to hear if you're willing to share the limitations you mentioned! will be helpful to pass along to the team :) and thanks for the kind words!!

for everyone else - the internal fix has been released for this so i'm going to make an attempt to put the next/image support back in. will keep you updated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: high type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants