0

I have nextjs project and I wanted to export static code so I can publish it. I tried first to create a build, but only what I got is this error below. I also tried to install it on my own swc but nothing is changed. Also, I tried to reset the cache, delete node modules and install again, but this not working too.

npm run build

> rus@0.1.0 build
> next build

warn  - Invalid next.config.js options detected: 
warn  -     The value at .output must be a string but it was an object.
warn  -     The value at .output must be one of: "standalone" or "export".
warn  - See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

info  - Using wasm build of next-swc
warn  - Attempted to load @next/swc-win32-x64-gnu, but it was not installed
warn  - Attempted to load @next/swc-win32-x64-msvc, but an error occurred: The specified module could not be found.  
\\?\C:\Users\Ufhcdj\Desktop\react\rus\node_modules\@next\swc-win32-x64-msvc\next-swc.win32-x64-msvc.node
Failed to compile.

HookWebpackError: File C:\Users\Ufhcdj\Desktop\react\rus\.next\server\app\icons\icon\[[...__metadata_id__]]\route.js does not exist.
    at makeWebpackError (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\webpack\bundle5.js:28:308185)
    at C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\webpack\bundle5.js:28:105236
    at eval (eval at create (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\webpack\bundle5.js:13:28771), <anonymous>:57:1)
    at C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\webpack\bundle5.js:28:68649
    at C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\build\webpack\plugins\next-trace-entrypoints-plugin.js:420:143
-- inner error --
Error: File C:\Users\Ufhcdj\Desktop\react\rus\.next\server\app\icons\icon\[[...__metadata_id__]]\route.js does not exist.
    at Job.emitDependency (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\@vercel\nft\index.js:1:39473)
    at async Promise.all (index 5)
    at async nodeFileTrace (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\@vercel\nft\index.js:1:35430)
    at async C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\build\webpack\plugins\next-trace-entrypoints-plugin.js:141:28
    at async Span.traceAsyncFn (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\trace\trace.js:97:20)      
    at async TraceEntryPointsPlugin.createTraceAssets (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\build\webpack\plugins\next-trace-entrypoints-plugin.js:95:9)
caused by plugins in Compilation.hooks.processAssets
Error: File C:\Users\Ufhcdj\Desktop\react\rus\.next\server\app\icons\icon\[[...__metadata_id__]]\route.js does not exist.
    at Job.emitDependency (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\@vercel\nft\index.js:1:39473)
    at async Promise.all (index 5)
    at async nodeFileTrace (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\compiled\@vercel\nft\index.js:1:35430)
    at async C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\build\webpack\plugins\next-trace-entrypoints-plugin.js:141:28
    at async Span.traceAsyncFn (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\trace\trace.js:97:20)      
    at async TraceEntryPointsPlugin.createTraceAssets (C:\Users\Ufhcdj\Desktop\react\rus\node_modules\next\dist\build\webpack\plugins\next-trace-entrypoints-plugin.js:95:9)


> Build failed because of webpack errors
info  - Creating an optimized production build .

This is my package.json

{
  "name": "rus",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "export": "next export",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "eslint": "8.39.0",
    "eslint-config-next": "13.3.1",
    "next": "^13.3.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

And my next.config.json

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    appDir: true,
  },

  output: {
    dir: "out",
  },
};

module.exports = nextConfig;
Boombaar
  • 147
  • 2
  • 9

1 Answers1

0

Your value for output in nextConfig is invalid - what you're looking for is distDir: 'out'.

As the console error is saying, output can only take a string value of 'standalone' or 'export' - it can also be left off entirely.

It also looks like you have a missing node module, check to be sure that particular package is present

jmcgriz
  • 2,819
  • 1
  • 9
  • 11
  • Okay nextConfig part you are right. But I tried to install node modules again and everything is same. – Boombaar Apr 26 '23 at 14:55
  • installing again won't fix it, if it's missing it'd be a problem with your package.json somehow. you should try searching before posting questions as well - it looks like that particular problem is addressed here already https://stackoverflow.com/questions/69816589/next-failed-to-load-swc-binary From that article, it's either a package-lock issue or depending on your environment one of a few other possible factors – jmcgriz Apr 26 '23 at 14:59