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

Cannot find module critters #157

Closed
mannycolon opened this issue Jan 21, 2021 · 15 comments · Fixed by netlify/zip-it-and-ship-it#307 or netlify/zip-it-and-ship-it#312
Closed

Cannot find module critters #157

mannycolon opened this issue Jan 21, 2021 · 15 comments · Fixed by netlify/zip-it-and-ship-it#307 or netlify/zip-it-and-ship-it#312
Labels
priority: high type: bug code to address defects in shipped code

Comments

@mannycolon
Copy link

[build]
  command = "npm run build"

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

Screen Shot 2021-01-21 at 3 47 42 PM
Screen Shot 2021-01-21 at 3 48 27 PM

@mannycolon mannycolon changed the title Builds start failing once upgraded next from 10.0.4 to 10.0.5 Builds fail when upgrading next from 10.0.4 to 10.0.5 Jan 22, 2021
@erezrokah
Copy link
Contributor

Hi @mannycolon 👋 This should have been fixed by netlify/zip-it-and-ship-it#295.
I get a Page Not Found when opening the build log link you've provided so it's probably private.

Can you share the following parts of your build logs:

  1. Buildbot version, should look like this;
    image
  2. Plugins versions, should look like this:
    image

If you have a public repo with a reproduction to share that would be awesome.

@mannycolon
Copy link
Author

mannycolon commented Jan 22, 2021

@mannycolon
Copy link
Author

@erezrokah Here's the log

3:40:31 PM: Build ready to start
3:40:33 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
3:40:33 PM: build-image tag: v3.6.1
3:40:33 PM: buildbot version: 2e994c874dd551982059545cd109ce3b21bce257
3:40:33 PM: Fetching cached dependencies
3:40:33 PM: Starting to download cache of 121.9MB
3:40:35 PM: Finished downloading cache in 2.239375826s
3:40:35 PM: Starting to extract cache
3:40:39 PM: Finished extracting cache in 3.803243403s
3:40:39 PM: Finished fetching cache in 6.084247498s
3:40:39 PM: Starting to prepare the repo for build
3:40:40 PM: Preparing Git Reference refs/heads/master
3:40:42 PM: Starting build script
3:40:42 PM: Installing dependencies
3:40:42 PM: Python version set to 2.7
3:40:42 PM: Started restoring cached node version
3:40:45 PM: Finished restoring cached node version
3:40:46 PM: v12.18.0 is already installed.
3:40:46 PM: Now using node v12.18.0 (npm v6.14.4)
3:40:46 PM: Started restoring cached build plugins
3:40:46 PM: Finished restoring cached build plugins
3:40:47 PM: Attempting ruby version 2.7.1, read from environment
3:40:48 PM: Using ruby version 2.7.1
3:40:48 PM: Using PHP version 5.6
3:40:48 PM: Started restoring cached node modules
3:40:48 PM: Finished restoring cached node modules
3:40:48 PM: Started restoring cached yarn cache
3:40:48 PM: Finished restoring cached yarn cache
3:40:49 PM: Installing NPM modules using Yarn version 1.22.4
3:40:49 PM: yarn install v1.22.4
3:40:49 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
3:40:49 PM: [1/4] Resolving packages...
3:40:50 PM: [2/4] Fetching packages...
3:40:58 PM: info [email protected]: The platform "linux" is incompatible with this module.
3:40:58 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
3:40:58 PM: info [email protected]: The platform "linux" is incompatible with this module.
3:40:58 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
3:40:58 PM: info [email protected]: The platform "linux" is incompatible with this module.
3:40:58 PM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
3:40:58 PM: [3/4] Linking dependencies...
3:41:02 PM: [4/4] Building fresh packages...
3:41:06 PM: Done in 16.78s.
3:41:06 PM: NPM modules installed using Yarn
3:41:06 PM: Started restoring cached go cache
3:41:06 PM: Finished restoring cached go cache
3:41:06 PM: go version go1.14.4 linux/amd64
3:41:06 PM: go version go1.14.4 linux/amd64
3:41:06 PM: Installing missing commands
3:41:06 PM: Verify run directory
3:41:08 PM: ​
3:41:08 PM: ────────────────────────────────────────────────────────────────
3:41:08 PM:   Netlify Build                                                 
3:41:08 PM: ────────────────────────────────────────────────────────────────
3:41:08 PM: ​
3:41:08 PM: ❯ Version
3:41:08 PM:   @netlify/build 8.1.0
3:41:08 PM: ​
3:41:08 PM: ❯ Flags
3:41:08 PM:   deployId: 6009e6bf6ff93b00084d588f
3:41:08 PM:   mode: buildbot
3:41:08 PM: ​
3:41:08 PM: ❯ Current directory
3:41:08 PM:   /opt/build/repo
3:41:08 PM: ​
3:41:08 PM: ❯ Config file
3:41:08 PM:   /opt/build/repo/netlify.toml
3:41:08 PM: ​
3:41:08 PM: ❯ Context
3:41:08 PM:   production
3:41:09 PM: ​
3:41:09 PM: ❯ Loading plugins
3:41:09 PM:    - @netlify/[email protected] from netlify.toml
3:41:09 PM: ​
3:41:09 PM: ────────────────────────────────────────────────────────────────
3:41:09 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
3:41:09 PM: ────────────────────────────────────────────────────────────────
3:41:09 PM: ​
3:41:09 PM: ** Warning: support for Next.js >=10.0.0 is experimental **
3:41:09 PM: ** Adding next.config.js with target set to 'serverless' **
3:41:09 PM: ​
3:41:09 PM: (@netlify/plugin-nextjs onPreBuild completed in 11ms)
3:41:09 PM: ​
3:41:09 PM: ────────────────────────────────────────────────────────────────
3:41:09 PM:   2. build.command from netlify.toml                            
3:41:09 PM: ────────────────────────────────────────────────────────────────
3:41:09 PM: ​
3:41:09 PM: $ npm run build
3:41:10 PM: > [email protected] build /opt/build/repo
3:41:10 PM: > next build
3:41:11 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
3:41:11 PM: info  - Creating an optimized production build...
3:41:25 PM: warn  - Compiled with warnings
3:41:25 PM: ./node_modules/next/dist/next-server/server/load-components.js
3:41:25 PM: Critical dependency: the request of a dependency is an expression
3:41:25 PM: ./node_modules/next/dist/next-server/server/load-components.js
3:41:25 PM: Critical dependency: the request of a dependency is an expression
3:41:25 PM: ./node_modules/next/dist/next-server/server/require.js
3:41:25 PM: Critical dependency: the request of a dependency is an expression
3:41:25 PM: ./node_modules/next/dist/next-server/server/require.js
3:41:25 PM: Critical dependency: the request of a dependency is an expression
3:41:25 PM: ./node_modules/next/dist/next-server/server/require.js
3:41:25 PM: Critical dependency: the request of a dependency is an expression
3:41:25 PM: ./node_modules/node-fetch/lib/index.js
3:41:25 PM: Module not found: Can't resolve 'encoding' in '/opt/build/repo/node_modules/node-fetch/lib'
3:41:25 PM: info  - Collecting page data...
3:41:26 PM: info  - Generating static pages (0/3)
3:41:26 PM: info  - Generating static pages (3/3)
3:41:26 PM: info  - Finalizing page optimization...
3:41:27 PM: Page                             Size     First Load JS
3:41:27 PM: ┌ ○ /                            1.18 kB          71 kB
3:41:27 PM: ├ ○ /404                         2.77 kB        65.9 kB
3:41:27 PM: ├ λ /api/show                    0 B            63.1 kB
3:41:27 PM: └ ● /news/[article]              1.13 kB          71 kB
3:41:27 PM: + First Load JS shared by all    63.1 kB
3:41:27 PM:   ├ chunks/commons.952812.js     13.3 kB
3:41:27 PM:   ├ chunks/framework.9d5241.js   41.8 kB
3:41:27 PM:   ├ chunks/main.ae4733.js        6.32 kB
3:41:27 PM:   ├ chunks/pages/_app.4acff8.js  1.01 kB
3:41:27 PM:   └ chunks/webpack.50bee0.js     751 B
3:41:27 PM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
3:41:27 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
3:41:27 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
3:41:27 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
3:41:27 PM: ​
3:41:27 PM: (build.command completed in 17.2s)
3:41:27 PM: ​
3:41:27 PM: ────────────────────────────────────────────────────────────────
3:41:27 PM:   3. onBuild command from @netlify/plugin-nextjs                
3:41:27 PM: ────────────────────────────────────────────────────────────────
3:41:27 PM: ​
3:41:27 PM: ** Running Next on Netlify package **
3:41:27 PM: 🚀 Next on Netlify 🚀
3:41:27 PM: 🌍️ Copying public/ folder to /opt/build/repo
3:41:27 PM: 💼 Copying static NextJS assets to /opt/build/repo
3:41:27 PM: 💫 Setting up API endpoints as Netlify Functions in netlify-automatic-functions
3:41:27 PM: 💫 Setting up pages with getInitialProps as Netlify Functions in netlify-automatic-functions
3:41:27 PM: 💫 Setting up pages with getServerSideProps as Netlify Functions in netlify-automatic-functions
3:41:27 PM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to /opt/build/repo
3:41:27 PM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in netlify-automatic-functions
3:41:27 PM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in netlify-automatic-functions
3:41:27 PM: 🔥 Copying pre-rendered pages without props to /opt/build/repo
3:41:27 PM: 🔀 Setting up redirects
3:41:27 PM: 🔀 Setting up headers
3:41:27 PM: ​
3:41:27 PM: (@netlify/plugin-nextjs onBuild completed in 216ms)
3:41:27 PM: ​
3:41:27 PM: ────────────────────────────────────────────────────────────────
3:41:27 PM:   4. Functions bundling                                         
3:41:27 PM: ────────────────────────────────────────────────────────────────
3:41:27 PM: ​
3:41:27 PM: Packaging Functions from netlify-automatic-functions directory:
3:41:27 PM:  - next_api_show/next_api_show.js
3:41:27 PM:  - next_news_article/next_news_article.js
3:41:31 PM: ​
3:41:31 PM: ────────────────────────────────────────────────────────────────
3:41:31 PM:   Dependencies installation error                               
3:41:31 PM: ────────────────────────────────────────────────────────────────
3:41:31 PM: ​
3:41:31 PM:   Error message
3:41:31 PM:   A Netlify Function failed to require one of its dependencies.
3:41:31 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:31 PM: ​
3:41:31 PM:   In file "/opt/build/repo/netlify-automatic-functions/next_news_article/next_news_article.js"
3:41:31 PM:   Cannot find module 'critters'
3:41:31 PM:   Require stack:
3:41:31 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:31 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:31 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:31 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
3:41:31 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/commands/get.js
3:41:31 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js
3:41:31 PM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js
3:41:31 PM: ​
3:41:31 PM:   Resolved config
3:41:31 PM:   build:
3:41:31 PM:     command: npm run build
3:41:31 PM:     commandOrigin: config
3:41:31 PM:   plugins:
3:41:31 PM:     - inputs: {}
3:41:31 PM:       origin: config
3:41:31 PM:       package: '@netlify/plugin-nextjs'
3:41:31 PM: Caching artifacts
3:41:31 PM: Started saving node modules
3:41:31 PM: Finished saving node modules
3:41:31 PM: Started saving build plugins
3:41:31 PM: Finished saving build plugins
3:41:31 PM: Started saving yarn cache
3:41:31 PM: Finished saving yarn cache
3:41:31 PM: Started saving pip cache
3:41:31 PM: Finished saving pip cache
3:41:31 PM: Started saving emacs cask dependencies
3:41:31 PM: Finished saving emacs cask dependencies
3:41:31 PM: Started saving maven dependencies
3:41:31 PM: Finished saving maven dependencies
3:41:31 PM: Started saving boot dependencies
3:41:31 PM: Finished saving boot dependencies
3:41:31 PM: Started saving rust rustup cache
3:41:31 PM: Finished saving rust rustup cache
3:41:31 PM: Started saving go dependencies
3:41:31 PM: Finished saving go dependencies
3:41:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:41:31 PM: Failing build: Failed to build site
3:41:31 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
3:41:31 PM: Finished processing build request in 58.071825047s

@mannycolon
Copy link
Author

mannycolon commented Jan 22, 2021

buildbot version: 2e994c874dd551982059545cd109ce3b21bce257
Loading plugins
@netlify/[email protected] from netlify.toml

Here's a repo I forked to showcase the error when upgrading to Next v10.0.5
https://github.com/mannycolon/next-prankz

@lindsaylevine lindsaylevine changed the title Builds fail when upgrading next from 10.0.4 to 10.0.5 Cannot find module critters Jan 24, 2021
@lindsaylevine lindsaylevine transferred this issue from opennextjs/opennextjs-netlify Jan 24, 2021
@lindsaylevine lindsaylevine added priority: high type: bug code to address defects in shipped code labels Jan 24, 2021
@neefrehman
Copy link

@lindsaylevine heya! continuing on from #103.

ah wait just realized you're using the CLI (i think)

I'm not using the CLI, just the github continuous integration.

here's the deploy link: https://app.netlify.com/teams/neef/builds/600d76a5b2138f000738f5dd

@ezekielaquino
Copy link

I'm also having this error! Occurred when I updated next to 10.0.5 and next-on-netlify to latest

@erezrokah
Copy link
Contributor

Hi everyone, sorry for the delay to respond. @mannycolon I forked you repo and updated to [email protected] and my build is passing. See https://github.com/erezrokah/next-prankz/commit/682f13dffe5350ea30d727b81285991f9b5aeac9 and https://app.netlify.com/sites/objective-cori-263efa/deploys/600f019de7f59c000714301b. Can you provide a step by step guide to reproduce the error?

For @neefrehman and @ezekielaquino can you share a public repo I can use to reproduce this?

@neefrehman
Copy link

@erezrokah here you go: https://github.com/neefrehman/allergies.travel/tree/staging. Note that the bug is only on the staging branch, as main still uses next export

@mannycolon
Copy link
Author

mannycolon commented Jan 26, 2021

@erezrokah It started working after your changes on netlify/build#2193, thanks

@erezrokah
Copy link
Contributor

@erezrokah here you go: https://github.com/neefrehman/allergies.travel/tree/staging. Note that the bug is only on the staging branch, as main still uses next export

Thanks @neefrehman that helps. I was able to reproduce the issue and will submit a fix soon.
As a workaround you can change this line:
https://github.com/neefrehman/allergies.travel/blob/f06dd33785de8125bfff15d275bb534e99319598/package.json#L36
to "next": "^10.0.0",

@erezrokah
Copy link
Contributor

FYI, we haven't released the fix to our production env yet - I'll follow up here once it's released

@erezrokah
Copy link
Contributor

This fixed was rolled out to our production environment. Please comment if the issue still persists

@jhesgodi
Copy link

jhesgodi commented Jan 29, 2021

@erezrokah thanks for putting time on the fixes. I think there could be another use case missing as of today I found the error again.
Please find:

@lindsaylevine
Copy link
Contributor

lindsaylevine commented Jan 29, 2021

@jhesgodi thanks for the repo and logs!! will defer to @erezrokah but just wanted to reopen and add that if you need features in the latest next version for whatever reason, another workaround is just to install critters. appreciate your patience!!!

@lindsaylevine lindsaylevine reopened this Jan 29, 2021
@erezrokah
Copy link
Contributor

erezrokah commented Jan 29, 2021

Thanks for reporting @jhesgodi - this is indeed a use case we didn't consider.
Our current logic looks as next version but won't match latest:
https://github.com/netlify/zip-it-and-ship-it/blob/c17440c2a14c35521cb123c51516d4d86645204e/src/node_dependencies/nested.js#L81

We're discussing a long term solution so plugins can customize our bundling logic.

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
6 participants