next.js: Error: Failed to read source code from `amp-dev.js`
What version of Next.js are you using?
12.0.5-canary.10-12.0.8
What version of Node.js are you using?
14.17.0
What browser are you using?
Not relevant
What operating system are you using?
Windows
How are you deploying your application?
Not relevant
Describe the Bug
I updated next.js
from v12.0.5-canary.9 to v12.0.5-canary.10 and I got a file not found error of amp-dev.js
.
Expected Behavior
No error.
To Reproduce
yarn init -y
yarn set version canary
yarn add next@canary react react-dom
- Create
pages
folder yarn next
- Read log:
(node:14180) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
error - ./.yarn/__virtual__/next-virtual-553eee263b/0/cache/next-npm-12.0.5-canary.10-1a75536391-cbd811bead.zip/node_modules/next/dist/client/dev/amp-dev.js
Error: Failed to read source code from C:\test-nextjs\.yarn\__virtual__\next-virtual-553eee263b\0\cache\next-npm-12.0.5-canary.10-1a75536391-cbd811bead.zip\node_modules\next\dist\client\dev\amp-dev.js
Caused by:
The system cannot find the path specified. (os error 3)
wait - compiling...
error - ./.yarn/__virtual__/next-virtual-553eee263b/0/cache/next-npm-12.0.5-canary.10-1a75536391-cbd811bead.zip/node_modules/next/dist/client/dev/amp-dev.js
Error: Failed to read source code from C:\test-nextjs\.yarn\__virtual__\next-virtual-553eee263b\0\cache\next-npm-12.0.5-canary.10-1a75536391-cbd811bead.zip\node_modules\next\dist\client\dev\amp-dev.js
Caused by:
The system cannot find the path specified. (os error 3)
wait - compiling...
error - ./.yarn/__virtual__/next-virtual-553eee263b/0/cache/next-npm-12.0.5-canary.10-1a75536391-cbd811bead.zip/node_modules/next/dist/client/dev/amp-dev.js
Error: Failed to read source code from C:\test-nextjs\.yarn\__virtual__\next-virtual-553eee263b\0\cache\next-npm-12.0.5-canary.10-1a75536391-cbd811bead.zip\node_modules\next\dist\client\dev\amp-dev.js
Caused by:
The system cannot find the path specified. (os error 3)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 17 (6 by maintainers)
This issue will be fixed with #33236
In
next.js
v12.0.5-canary.14, it’s fixed adding innext.config.js
file:This issue, should be fixed with #31995 (already merged in canary branch). Waiting release of
next.js
v12.0.5-canary.14 to test.This issue persists with all latest yarn versions (currently 3.1.1 and 3.2.0-rc.6)
Maybe it works (bug #31552 blocks compiling after this issue is solved)
Without
swcFileReading: false
, it still persists with random output errors:I’m keeping this issue opened because of the temporary workaround with
swcFileReading
.This sounds like the problematic commit: https://github.com/vercel/next.js/pull/31682
cc @sokra
I suspect this is caused by Next reading files on the wasm/rust side rather than JS. It means it doesn’t go through the layer Yarn puts in place so that dependencies can be accessed directly from their zip archives.
The simplest fix preserving the intent would be for Next to fallback to using the
fs.readFileSync
method if it detects.yarn
in the file path.I tried setting nodeLinker back to node-modules and that was a workaround. But also loading time went x100 because of that. So hopefully the fixes they are pushing will fix these issues so we can use yarn pnp 😃