Skip to content

ReferenceError: _self___NEXT_DATA___autoExport is not defined on next dev (16.1.4) #88780

@leeeunsang-tmobi

Description

@leeeunsang-tmobi

Link to the code that reproduces this issue

https://github.com/leeeunsang-tmobi/next-reproduction-16.1.4

To Reproduce

  1. pnpm install
  2. pnpm dev

Current vs. Expected behavior

Actual behavior:
next dev starts successfully, but the browser throws a runtime script error on load:

index.tsx:315 Uncaught ReferenceError: _self___NEXT_DATA___autoExport is not defined
    at AppContainer (index.tsx:315:27)
    at Object.react_stack_bottom_frame (react-dom-client.development.js:25904:20)
    at renderWithHooks (react-dom-client.development.js:7662:22)
    at updateFunctionComponent (react-dom-client.development.js:10166:19)
    at beginWork (react-dom-client.development.js:11778:18)
    at runWithFiberInDEV (react-dom-client.development.js:871:30)
    at performUnitOfWork (react-dom-client.development.js:17641:22)
    at workLoopSync (react-dom-client.development.js:17469:41)
    at renderRootSync (react-dom-client.development.js:17450:11)
    at performWorkOnRoot (react-dom-client.development.js:16583:35)
    at performWorkOnRootViaSchedulerTask (react-dom-client.development.js:18957:7)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:45:48)

Expected behavior:
next dev starts successfully and the page loads without browser‑side runtime errors.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.28.1
Relevant Packages:
  next: 16.1.4 // Latest available version is detected (16.1.4).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Regression:

  • Works on 16.1.1
  • Also works on 16.1.4 if I remove package.json#browserslist or override @next/swc-darwin-arm64@16.1.1.

Browserslist config:

  "browserslist": {
    "development": ["last 2 versions"],
    "production": ["chrome 72"]
  }

Diff notes
The var _self___NEXT_DATA___autoExport declaration moved out of AppContainer and into a nested Component function in 16.1.4 but the AppContainer still uses the variable.
This change causes the browser‑side error index.tsx:315 Uncaught ReferenceError: _self___NEXT_DATA___autoExport is not defined.

working

  function AppContainer(param) {
    var children = param.children;
    _s();
    var adaptedForAppRouter = _react.default.useMemo(...);
    var _self___NEXT_DATA___autoExport;
    return /*#__PURE__*/ (0,_jsxruntime.jsx)(_adapters.PathnameContextProviderAdapter, {
      router: router,
      isAutoExport: (_self___NEXT_DATA___autoExport = self.__NEXT_DATA__.autoExport) !== null && _self___NEXT_DATA___autoExport !== void 0 ? _self___NEXT_DATA___autoExport : false,
      ...
    });
  }

broken

  function AppContainer(param) {
    var children = param.children;
    _s();
    var adaptedForAppRouter = _react.default.useMemo(...);
    return /*#__PURE__*/ (0,_jsxruntime.jsx)(_adapters.PathnameContextProviderAdapter, {
      router: router,
      isAutoExport: (_self___NEXT_DATA___autoExport = self.__NEXT_DATA__.autoExport) !== null && _self___NEXT_DATA___autoExport !== void 0 ? _self___NEXT_DATA___autoExport : false,
      ...
    });
  }

  // The declaration is moved down into a nested Component function:
  Component: function() {
    var _self___NEXT_DATA___autoExport;
    return null;
  }

Workarounds:

  • Remove package.json#browserslist, or
  • Override @next/swc-darwin-arm64@16.1.1 (downgrade swc).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pages RouterRelated to Pages Router.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions