question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiling with Warnings

See original GitHub issue

Bug report

Describe the bug

When building the project locally and on Now I’m getting these warnings:

Compiled with warnings.

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

To Reproduce

1- Have a simple next.js app and try build

Expected behavior

No warnings

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS 10.14.6
  • Version of Next.js: Same issue on 9.2.1 and 9.2.3-canary.8

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:16
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

18reactions
Tengacommented, Apr 16, 2020

@timneutkens Not sure if this was addressed through some other issue, but if repro steps are needed to reopen this, I can repro this with nothing but the starter template (which pulls next@9.3.5).

Repro steps:

module.exports = {
  target: 'serverless',
}
  • npm run build

Result is:

Console output

Creating an optimized production build

Compiled with warnings.

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

Automatically optimizing pages

Page                                                           Size     First Load JS
┌ ○ /                                                          6.95 kB          65 kB
└ ○ /404                                                       3.15 kB        61.2 kB
+ First Load JS shared by all                                  58.1 kB
  ├ static/pages/_app.js                                       957 B
  ├ chunks/f55b18d155ba108da95e069adbd66fd30ee008df.82b733.js  10.5 kB
  ├ chunks/framework.0f140d.js                                 40 kB
  ├ runtime/main.235c69.js                                     5.95 kB
  └ runtime/webpack.b65cab.js                                  746 B

λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)

✨  Done in 7.42s.

Additional info:

I’ve been downgrading Next to see if I can see when this started happening, and I’ve observed that next@9.2.2 seems to be the first version that is showing this issue (next@9.2.1 logging no warnings).


Sounds expected, it means you’re importing a library that uses expression requires. Warning can be ignored just fine. eg the dep will have something like this:

require(`./something/from/somewhere/${variable}`)

Unless this is expected from Next itself by default, it does not seem like a user added dependency is causing this, considering it can be reproed with the starter template?

Hopefully it’s useful.

12reactions
mikestopcontinuescommented, May 2, 2020

Shouldn’t this be reopened? I’m experiencing this issue as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiler warnings - IBM
Warnings indicate other unusual conditions in your code that might indicate a problem, although compilation can (and does) proceed.
Read more >
Why Bother with Compiler Warnings? - Cprogramming.com
Compilers emit both erorrs, which prevent your code from compiling at all, and warnings, which indicate a potential problem, but still let your...
Read more >
Why should I always enable compiler warnings?
A compiler warning signals a potentially serious problem in your code. The problems listed above are almost always fatal; others may or may...
Read more >
Warning Options (Using the GNU Compiler Collection (GCC))
3.8 Options to Request or Suppress Warnings. Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky ......
Read more >
7.3. Compile Errors and Warnings
Compile errors and warnings. A compile error happens when the compiler reports something wrong with your program, and does not produce a machine-language ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found