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

Error when copying .next/static/ #102

Closed
ehmicky opened this issue Nov 25, 2020 · 3 comments · Fixed by #148
Closed

Error when copying .next/static/ #102

ehmicky opened this issue Nov 25, 2020 · 3 comments · Fixed by #148
Labels
priority: medium type: bug code to address defects in shipped code

Comments

@ehmicky
Copy link
Contributor

ehmicky commented Nov 25, 2020

The following build fails with:

────────────────────────────────────────────────────────────────
  Plugin "@netlify/plugin-nextjs" internal error                
────────────────────────────────────────────────────────────────

  Error message
  Error: ENOENT: no such file or directory, stat '.next/static'

  Plugin details
  Package:        @netlify/plugin-nextjs
  Version:        1.0.2
  Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
  npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
  Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues

  Error location
  In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
      at Object.statSync (fs.js:933:3)
      at Object.statSync (/opt/buildhome/.netlify-build-plugins/node_modules/graceful-fs/polyfills.js:307:34)
      at statSync (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/util/stat.js:10:52)
      at getStatsSync (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/util/stat.js:24:19)
      at Object.checkPathsSync (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/util/stat.js:49:33)
      at copySync (/opt/buildhome/.netlify-build-plugins/node_modules/fs-extra/lib/copy-sync/copy-sync.js:24:38)
      at copyNextAssets (/opt/buildhome/.netlify-build-plugins/node_modules/next-on-netlify/lib/steps/copyNextAssets.js:10:3)
      at nextOnNetlify (/opt/buildhome/.netlify-build-plugins/node_modules/next-on-netlify/index.js:25:3)
      at onBuild (/opt/buildhome/.netlify-build-plugins/node_modules/@netlify/plugin-nextjs/index.js:78:5)
      at async Object.run (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/run.js:19:3)

The problem seems to be there:

join(NEXT_DIST_DIR, "static"),

This specific build does not have a .next/static/ directory, so trying to copy it fails.
I am not sure whether this is valid for .next/static/ not to exist. If it is valid, then this function should not copy anything if .next/static/ does not exist. If it is not valid, this function should throw with an error indicating the site has some configuration issues.

@ehmicky ehmicky added the type: bug code to address defects in shipped code label Nov 25, 2020
@ehmicky ehmicky changed the title ENOENT: no such file or directory, stat '.next/static' Error when copying .next/static Nov 25, 2020
@ehmicky ehmicky changed the title Error when copying .next/static Error when copying .next/static/ Nov 25, 2020
@mrpaulphan
Copy link

Has this been resolved? I'm also having the exact same issue.

@fittotweet
Copy link

fittotweet commented Dec 13, 2020

(total noob here (first comment ever!)). I just ran into this as well. I had to manually create a next.config.js file w target set to 'serverless' and run 'npx next build' to create the missing files/folders in the .next folder. Am not getting that plugin error now.

update: It broke again when I added .next to .gitignore and that made me realize that my netlify.toml file didn't have the correct "npm run build" command in it. Doh!

@lindsaylevine
Copy link
Contributor

@mrpaulphan @olegrjumin are you still experiencing this issue when using next-on-netlify? if so, can you provide these details about your setup?

  1. netlify.toml
  2. build command (if your toml build command is an npm script pointing to the actual command)

seems like @fittotweet's issue was resolved by using the correct configuration :)

i don't think it's possible to not have .next/static if you're running next build at any point in your build/deploy process.

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

Successfully merging a pull request may close this issue.

4 participants