Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
2 of 7 tasks
milesj opened this issue Sep 4, 2023 · 11 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@milesj
Copy link
Contributor

milesj commented Sep 4, 2023

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

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.
@milesj milesj added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 4, 2023
@Josh-Cena
Copy link
Collaborator

I can't reproduce this locally either...

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

@Josh-Cena Josh-Cena added status: needs more information There is not enough information to take action on the issue. and removed status: needs triage This issue has not been triaged by maintainers labels Sep 5, 2023
@milesj
Copy link
Contributor Author

milesj commented Sep 5, 2023

@Josh-Cena Yup it works in 20.5: https://github.com/moonrepo/moon/actions/runs/6079098874/job/16491161043?pr=1037

@Shalevos
Copy link

Shalevos commented Sep 5, 2023

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

@milesj
Copy link
Contributor Author

milesj commented Sep 5, 2023

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

@Josh-Cena
Copy link
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.

@quality-leftovers
Copy link

quality-leftovers commented Sep 6, 2023

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

mschreier-tableau added a commit to tableau/hyper-db that referenced this issue Sep 6, 2023
mschreier-tableau added a commit to tableau/hyper-db that referenced this issue Sep 6, 2023
* Add upcoming section for Sep 2023 release

* Document support for connecting to other Hyper processes not spawned by the own program

* Update version for upcoming September release

* Fix node version to 20.5 due to a bug
See issue: facebook/docusaurus#9278

---------

Co-authored-by: Dimitri Vorona <dvorona@tableau.com>
Co-authored-by: Adrian Vogelsgesang <avogelsgesang@salesforce.com>
@cmdcolin
Copy link
Contributor

cmdcolin commented Sep 6, 2023

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 

> my-website@0.0.0 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

@slorber
Copy link
Collaborator

slorber commented Sep 7, 2023

Probably related to nodejs/node#49497

mfocko added a commit to mfocko/blog that referenced this issue Sep 7, 2023
Context: facebook/docusaurus#9278

Signed-off-by: Matej Focko <me@mfocko.xyz>
@josephw-ml
Copy link

josephw-ml commented Sep 7, 2023

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

@ayhoung
Copy link

ayhoung commented Sep 8, 2023

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

@slorber
Copy link
Collaborator

slorber commented Sep 8, 2023

Duplicate of #9291

@slorber slorber marked this as a duplicate of #9291 Sep 8, 2023
@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2023
@slorber slorber added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs more information There is not enough information to take action on the issue. labels Sep 8, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

No branches or pull requests

8 participants