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.

`next dev` and `next build` broken on Yarn PnP in the latest release

See original GitHub issue

What version of Next.js are you using?

v12.0.5

What version of Node.js are you using?

v16.13.1

What browser are you using?

N/A

What operating system are you using?

Windows 11 (Build 22509.1000)

How are you deploying your application?

yarn next build && yarn next start

Describe the Bug

Getting the following errors on running yarn next build:

$ yarn next build
info  - Checking validity of types
warn  - No ESLint configuration detected. Run next lint to begin setup
info  - Creating an optimized production build
Failed to compile.

./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/client/index.js
Error: Failed to read source code from C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\client\index.js

Caused by:
    The system cannot find the path specified. (os error 3)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/client/next.js

./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/client/request-idle-callback.js
Error: Failed to read source code from C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\client\request-idle-callback.js

Caused by:
    The system cannot find the path specified. (os error 3)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/client/route-loader.js
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/shared/lib/router/router.js
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/client/router.js

./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/pages/_app.js
Error: Failed to read source code from C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\pages\_app.js

Caused by:
    The system cannot find the path specified. (os error 3)

./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/shared/lib/head.js
Error: Failed to read source code from C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\shared\lib\head.js

Caused by:
    The system cannot find the path specified. (os error 3)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/pages/_error.js

./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/shared/lib/mitt.js
Error: Failed to read source code from C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\shared\lib\mitt.js

Caused by:
    The system cannot find the path specified. (os error 3)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/shared/lib/router/router.js
./.yarn/__virtual__/next-virtual-fedb67b0ce/0/cache/next-npm-12.0.5-1c991f073c-616235e394.zip/node_modules/next/dist/client/router.js


> Build failed because of webpack errors

The issue seems to be SWC related. After creating .babelrc with next/babel preset, the yarn next build command is working but yarn next dev is still throwing error.

Also, why the Checking validity of types log is shown even if someone is not using TS?

Expected Behavior

To build successfully and start as happens in next@12.0.4.

To Reproduce

mkdir foo && cd "$_"
yarn init -2
yarn add next react react-dom
mkdir pages
echo 'export default () => <div>Hello World</div>' > pages/index.js
yarn next build

Based on https://github.com/yarnpkg/berry/blob/master/.github/workflows/e2e-next-workflow.yml

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:38
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

15reactions
brc-ddcommented, Dec 5, 2021

@timneutkens next build is working after setting that, but next dev is still throwing errors:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

error - ./.yarn/__virtual__/react-dom-virtual-7a7367685f/0/cache/react-dom-npm-17.0.2-f551215af1-1c1eaa3bca.zip/node_modules/react-dom/cjs/react-dom.development.js
Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (-2147483514)
    at new Promise (<anonymous>)
wait  - compiling...
error - ./.yarn/__virtual__/react-dom-virtual-7a7367685f/0/cache/react-dom-npm-17.0.2-f551215af1-1c1eaa3bca.zip/node_modules/react-dom/cjs/react-dom.development.js
Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (-2147483418)
    at new Promise (<anonymous>)
wait  - compiling...
error - ./.yarn/__virtual__/react-dom-virtual-7a7367685f/0/cache/react-dom-npm-17.0.2-f551215af1-1c1eaa3bca.zip/node_modules/react-dom/cjs/react-dom.development.js
Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (-2147483418)
    at new Promise (<anonymous>)
(node:13216) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
wait  - compiling /_error (client and server)...
error - ./.yarn/__virtual__/react-dom-virtual-7a7367685f/0/cache/react-dom-npm-17.0.2-f551215af1-1c1eaa3bca.zip/node_modules/react-dom/cjs/react-dom.development.js
Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (-2147483418)
    at new Promise (<anonymous>)
error - Error: Qualified path resolution failed - none of those files can be found on the disk.

Source path: C:\Users\brc-dd\Desktop\foo\.next\fallback-build-manifest.json
Not found: C:\Users\brc-dd\Desktop\foo\.next\fallback-build-manifest.json
Not found: C:\Users\brc-dd\Desktop\foo\.next\fallback-build-manifest.json.js
Not found: C:\Users\brc-dd\Desktop\foo\.next\fallback-build-manifest.json.json
Not found: C:\Users\brc-dd\Desktop\foo\.next\fallback-build-manifest.json.node

Require stack:
- C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\server\load-components.js
- C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\build\utils.js
- C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\build\output\store.js
- C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\build\output\index.js
- C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\cli\next-dev.js
- C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\bin\next
    at Function.external_module_.Module._resolveFilename (C:\Users\brc-dd\Desktop\foo\.pnp.cjs:13363:55)
    at Function.mod._resolveFilename (C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\build\webpack\require-hook.js:171:28)
    at Function.external_module_.Module._load (C:\Users\brc-dd\Desktop\foo\.pnp.cjs:13162:48)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.loadDefaultErrorComponents (C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\server\load-components.js:22:24)
    at DevServer.getFallbackErrorComponents (C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\server\dev\next-dev-server.js:679:43)
    at async DevServer.renderErrorToResponse (C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\server\next-server.js:1738:40)
    at async pipe.req.req (C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\server\next-server.js:1678:30)
    at async DevServer.pipe (C:\Users\brc-dd\Desktop\foo\.yarn\__virtual__\next-virtual-fedb67b0ce\0\cache\next-npm-12.0.5-1c991f073c-616235e394.zip\node_modules\next\dist\server\next-server.js:1156:25)

PS: This is happening since v12.0.5-canary.0.

Related Issues - #31552, #31812

12reactions
dlindenkreuzcommented, Dec 13, 2021

This prevents me from using Next.js >= v12.0.5.

Edit: node v16.13.1, macOS 12.0.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js with Yarn pnp in a mono repo keep failing when trying ...
It seems like the main problem here is the build tool, because when I run the Next.js server itself ( yarn dev )...
Read more >
Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >
npm, pnpm, and Yarn | IntelliJ IDEA Documentation - JetBrains
IntelliJ IDEA also lets you run and debug npm, Yarn, and pnpm scripts. ... Update package to latest version: quick-fix ... next to...
Read more >
next-transpile-modules - npm
The way to fix it is easy, and it is what you should always do: install your dependencies with npm ci ("clean install")...
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