Skip to content

Error in Node.js v20.6.0: "TypeError: Cannot set property NODE_MAJOR_VERSION of #<Object> which has only a getter" #9278

Closed as not planned

Description

@milesj

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Docusaurus builds are failing in CI with:

       website:build | /home/runner/work/moon/moon/node_modules/@docusaurus/utils/lib/index.js:9
       website:build | exports.replaceMarkdownLinks = exports.writeMarkdownHeadingId = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = exports.localizePath = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
       website:build |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
       website:build | 
       website:build | TypeError: Cannot set property NODE_MAJOR_VERSION of #<Object> which has only a getter
       website:build |     at Object.<anonymous> (/home/runner/work/moon/moon/node_modules/@docusaurus/utils/lib/index.js:9:1421)
       website:build |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
       website:build |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
       website:build |     at Module.load (node:internal/modules/cjs/loader:1091:32)
       website:build |     at Module._load (node:internal/modules/cjs/loader:938:12)
       website:build |     at Module.require (node:internal/modules/cjs/loader:1115:19)
       website:build |     at require (node:internal/modules/helpers:130:18)
       website:build |     at Object.<anonymous> (/home/runner/work/moon/moon/node_modules/@docusaurus/utils/lib/dataFileUtils.js:15:17)
       website:build |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
       website:build |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)

Reproducible demo

No response

Steps to reproduce

I'm like 99% sure this is caused by Node.js v20.6.0, which came out today, the same time these errors started cropping up: https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#20.6.0

However, this seems to only happen in CI and not locally. https://github.com/moonrepo/moon/actions/runs/6078432962/job/16489581930?pr=1037

Expected behavior

It builds correctly.

Actual behavior

It fails with a non-fixable error.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.

Activity

  1. added
    bug
    status: needs triage
    on Sep 4, 2023
  2. Josh-Cena commented on Sep 5, 2023

    @Josh-Cena
    Collaborator

    I can't reproduce this locally either...

    Does it work if you downgrade your Node version in your CI?

  3. added
    status: needs more information
    and removed
    status: needs triage
    on Sep 5, 2023
  4. milesj commented on Sep 5, 2023

    @milesj
    ContributorAuthor
  5. Shalevos commented on Sep 5, 2023

    @Shalevos

    I'm also experiencing this when building with node v20.6.0 .
    This happens when running locally as well as on Render.

  6. milesj commented on Sep 5, 2023

    @milesj
    ContributorAuthor

    We may need to report this to node, but I'm not entirely sure how to phrase it...

  7. Josh-Cena commented on Sep 5, 2023

    @Josh-Cena
    Collaborator

    It would help if someone can reproduce this locally. From there, we can try to minimize the reproduction because it obviously involves transpiled CJS code.

  8. quality-leftovers commented on Sep 6, 2023

    @quality-leftovers

    Also affected in ci-pipeline using node:latest image for build. It's a private repo so cannot help with reproducing.

  9. cmdcolin commented on Sep 6, 2023

    @cmdcolin
    Contributor

    this can be reproduced locally if you install the specific version of node 20.6.0. can use "fnm" or "nvm" or similar to get versions currently 20.6.0 also runs into #9286 so to reproduce, you can use an old version of node to create the docusaurus instance, then the newer version hits the error

    shell log

    % fnm use 20.2.0
    Using Node v20.2.0
    
    % npx create-docusaurus@latest my-website classic
    ...stuff...
    
    
    % cd my-website
    
    % npm i
    
    ...stuff...
    
    % npm run build
    
    ...still using the v20.2.0, works...
    
    % fnm use 20.6.0
    Using Node v20.6.0
    
    % npm run build 
    
    > [email protected] build
    > docusaurus build
    
    /home/cdiesh/my-website/node_modules/@docusaurus/utils/lib/index.js:9
    exports.replaceMarkdownLinks = exports.writeMarkdownHeadingId = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = exports.localizePath = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
    
    TypeError: Cannot set property NODE_MAJOR_VERSION of #<Object> which has only a getter
        at Object.<anonymous> (/home/cdiesh/my-website/node_modules/@docusaurus/utils/lib/index.js:9:1421)
        at Module._compile (node:internal/modules/cjs/loader:1241:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
        at Module.load (node:internal/modules/cjs/loader:1091:32)
        at Module._load (node:internal/modules/cjs/loader:938:12)
        at Module.require (node:internal/modules/cjs/loader:1115:19)
        at require (node:internal/modules/helpers:130:18)
        at Object.<anonymous> (/home/cdiesh/my-website/node_modules/@docusaurus/utils/lib/dataFileUtils.js:15:17)
        at Module._compile (node:internal/modules/cjs/loader:1241:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    
    Node.js v20.6.0
    
  10. slorber commented on Sep 7, 2023

    @slorber
    Collaborator

    Probably related to nodejs/node#49497

  11. added a commit that references this issue on Sep 7, 2023
  12. josephw-ml commented on Sep 7, 2023

    @josephw-ml

    In case this helps reproducibility:
    I reproduce this error (reliably) using a docker/containerfile.
    One can get the template docusaurus example, add this containerfile, and then build the container to reproduce.

    FROM node:20.6-alpine
    WORKDIR /app
    COPY package.json package-lock.json ./
    RUN npm install --only=production
    COPY . .
    RUN npm run build
    
    
  13. ayhoung commented on Sep 8, 2023

    @ayhoung

    also getting this error with v20.6.:

    node_modules/@docusaurus/utils/lib/index.js:9
    exports.replaceMarkdownLinks = exports.writeMarkdownHeadingId = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = exports.localizePath = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
    TypeError: Cannot set property NODE_MAJOR_VERSION of #<Object> which has only a getter
        at Object.<anonymous> (/Users/allenhoung/aquivio/aquivio-docs/node_modules/@docusaurus/utils/lib/index.js:9:1421)
        at Module._compile (node:internal/modules/cjs/loader:1241:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
        at Module.load (node:internal/modules/cjs/loader:1091:32)
        at Module._load (node:internal/modules/cjs/loader:938:12)
        at Module.require (node:internal/modules/cjs/loader:1115:19)
        at require (node:internal/modules/helpers:130:18)
        at Object.<anonymous> (/Users/allenhoung/aquivio/aquivio-docs/node_modules/@docusaurus/utils/lib/dataFileUtils.js:15:17)
        at Module._compile (node:internal/modules/cjs/loader:1241:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    
    Node.js v20.6.0
    
  14. slorber commented on Sep 8, 2023

    @slorber
    Collaborator

    Duplicate of #9291

  15. added
    closed: duplicate
    and removed
    status: needs more information
    on Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclosed: duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions