Skip to content

[bug] npx create-docusaurus failing on node.js 20.6.0 npm 10.0.0 #9286

Closed as not planned

Description

@homotechsual

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

Cannot create site using npx create-docusaurus using node v 20.6.0 - fails with common.register is not a function.

This works if reverting back to node LTS.

Reproducible demo

No response

Steps to reproduce

Install node version 20.6.0
Install npm version 10.0.0

Run npx create-docusaurus@latest docusaurusnode20test classic --typescript

Expected behavior

Should create a new docusaurus classic site using Typescript.

Actual behavior

Errors:

PS>npx create-docusaurus@latest docusaurusnode20test classic --typescript
Need to install the following packages:
create-docusaurus@2.4.1
Ok to proceed? (y)
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
(node:29016) Warning: Accessing non-existent property 'register' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
[ERROR] TypeError: common.register is not a function

Your environment

  • Docusaurus version used: 2.4.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 20.6.0, NPM 10.0.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 11 Pro

Self-service

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

Activity

  1. added
    bugAn error in the Docusaurus core causing instability or issues with its execution
    status: needs triageThis issue has not been triaged by maintainers
    on Sep 6, 2023
  2. rogervdf commented on Sep 6, 2023

    @rogervdf

    Similar issue starting a few hours ago:

    #17 10.28 [ERROR] TypeError: common.register is not a function
    #17 10.30 npm notice 
    #17 10.30 npm notice New major version of npm available! 9.8.1 -> 10.0.0
    #17 10.30 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.0.0>
    #17 10.30 npm notice Run `npm install -g npm@10.0.0` to update!
    #17 10.30 npm notice 
    #17 ERROR: process "/bin/sh -c npx --yes create-docusaurus@latest template classic" did not complete successfully: exit code: 1
    

    I can also confirm that by pinning at 20.5 all is good, it's 20.6 specifically that breaks something

  3. slorber commented on Sep 7, 2023

    @slorber
    Collaborator

    Wonder if it's related to #9278, will investigate later

  4. slorber commented on Sep 7, 2023

    @slorber
    Collaborator

    Probably related to nodejs/node#49497

  5. Seburan commented on Sep 8, 2023

    @Seburan

    we started also to get the same error on september 6th when running "docusaurus build" in our CI/CD pipeline on Cloud Build using the default "node:latest" image.

    Step #5 - "npm-run-build-home": > docusaurus build
    Step #5 - "npm-run-build-home": 
    Step #5 - "npm-run-build-home": /workspace/services/home/node_modules/@docusaurus/utils/lib/index.js:9
    Step #5 - "npm-run-build-home": 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;
    Step #5 - "npm-run-build-home":                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
    Step #5 - "npm-run-build-home": 
    Step #5 - "npm-run-build-home": TypeError: Cannot set property NODE_MAJOR_VERSION of #<Object> which has only a getter
    Step #5 - "npm-run-build-home":     at Object.<anonymous> (/workspace/services/home/node_modules/@docusaurus/utils/lib/index.js:9:1421)
    Step #5 - "npm-run-build-home":     at Module._compile (node:internal/modules/cjs/loader:1241:14)
    Step #5 - "npm-run-build-home":     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    Step #5 - "npm-run-build-home":     at Module.load (node:internal/modules/cjs/loader:1091:32)
    Step #5 - "npm-run-build-home":     at Module._load (node:internal/modules/cjs/loader:938:12)
    Step #5 - "npm-run-build-home":     at Module.require (node:internal/modules/cjs/loader:1115:19)
    Step #5 - "npm-run-build-home":     at require (node:internal/modules/helpers:130:18)
    Step #5 - "npm-run-build-home":     at Object.<anonymous> (/workspace/services/home/node_modules/@docusaurus/utils/lib/dataFileUtils.js:15:17)
    Step #5 - "npm-run-build-home":     at Module._compile (node:internal/modules/cjs/loader:1241:14)
    Step #5 - "npm-run-build-home":     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    Step #5 - "npm-run-build-home": 
    Step #5 - "npm-run-build-home": Node.js v20.6.0
    

    now reverting to build image "node:lts" until it's fixed.

  6. added
    closed: duplicateThis issue or pull request already exists in another issue or pull request
    on Sep 8, 2023
  7. slorber commented on Sep 8, 2023

    @slorber
    Collaborator

    Duplicate of #9291

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

    bugAn error in the Docusaurus core causing instability or issues with its executionclosed: duplicateThis issue or pull request already exists in another issue or pull request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions