ReferenceError:fs.js 中未定义原基

问题描述 投票:0回答:1

我已经使用 NVM (v0.40.1) 安装了最新版本的 Node (v22.9.0) 和 NPM (v10.8.3)。我正在尝试建立一个 Hugo 网站。初始化

npm init
后,当我运行
npm-check
时,出现以下错误:

getting-started % npm run npm-check

> [email protected] npm-check
> npm-check -u

fs.js:44
} = primordials;
    ^

ReferenceError: primordials is not defined
    at fs.js:44:5
    at req_ (/Users/User/Desktop/getting-started/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/Users/User/Desktop/getting-started/node_modules/natives/index.js:55:10)
    at Object.<anonymous> (/Users/User/Desktop/getting-started/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)

Node.js v22.9.0

我已经运行了

npm ls natives
,但它显示
empty

% npm ls natives
[email protected] /Users/User/Desktop/getting-started
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]

我也跑过

npm audit fix
:

npm audit fix

up to date, audited 1 package in 140ms

运行

package.json
时创建的
npm init
文件如下所示:

{
  "name": "getting-started",
  "version": "1.0.0",
  "description": "A Hugo template for NPM",
  "main": "index.js",
  "scripts": {
    "npm-check": "npm-check -u"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "npm-check": "^3.2.10"
  },
  "dependencies": {
    "abbrev": "^1.1.1",
    "acorn": "^5.7.4",
    "ajv": "^6.12.6",
    "ansi-regex": "^2.1.1",
    "ansi-styles": "^2.2.1",
    "aproba": "^2.0.0",
    "are-we-there-yet": "^4.0.2",
    "argparse": "^1.0.10",
    "array-union": "^1.0.2",
    "array-uniq": "^1.0.3",
    "asn1": "^0.2.6",
    "assert-plus": "^1.0.0",
    "async": "^0.9.2",
    "asynckit": "^0.4.0",
    "aws-sign2": "^0.7.0",
    "aws4": "^1.13.2",
    "balanced-match": "^1.0.2",
    "bcrypt-pbkdf": "^1.0.2",
    "brace-expansion": "^1.1.11",
    "buffer-from": "^1.1.2",
    "buffered-spawn": "^1.1.2",
    "caseless": "^0.12.0",
    "chalk": "^1.1.3",
    "chownr": "^0.0.2",
    "cli-width": "^1.1.1",
    "color-support": "^1.1.3",
    "combined-stream": "^1.0.8",
    "commander": "^2.20.3",
    "concat-map": "^0.0.1",
    "concat-stream": "^1.6.2",
    "config-chain": "^1.1.13",
    "configstore": "^0.3.2",
    "console-control-strings": "^1.1.0",
    "core-util-is": "^1.0.3",
    "cross-spawn-async": "^1.0.1",
    "dashdash": "^1.14.1",
    "deep-extend": "^0.6.0",
    "defined": "^1.0.1",
    "delayed-stream": "^1.0.0",
    "depcheck": "^0.4.7",
    "detective": "^4.7.1",
    "duplexify": "^3.7.1",
    "ecc-jsbn": "^0.1.2",
    "emoji-regex": "^8.0.0",
    "end-of-stream": "^1.4.4",
    "err-code": "^0.1.2",
    "escape-string-regexp": "^1.0.5",
    "esprima": "^4.0.1",
    "extend": "^3.0.2",
    "extsprintf": "^1.3.0",
    "fast-deep-equal": "^3.1.3",
    "fast-json-stable-stringify": "^2.1.0",
    "figures": "^1.7.0",
    "forever-agent": "^0.6.1",
    "form-data": "^2.3.3",
    "fs.realpath": "^1.0.0",
    "function-bind": "^1.1.2",
    "gauge": "^5.0.2",
    "getpass": "^0.1.7",
    "giturl": "^0.0.3",
    "glob": "^4.5.3",
    "globby": "^1.2.0",
    "got": "^3.3.1",
    "graceful-fs": "^3.0.12",
    "har-schema": "^2.0.0",
    "har-validator": "^5.1.5",
    "has-ansi": "^2.0.0",
    "has-unicode": "^2.0.1",
    "hasown": "^2.0.2",
    "hosted-git-info": "^2.8.9",
    "http-signature": "^1.2.0",
    "infinity-agent": "^2.0.3",
    "inflight": "^1.0.6",
    "inherits": "^2.0.4",
    "ini": "^1.3.8",
    "inquirer": "^0.8.5",
    "is-core-module": "^2.15.1",
    "is-fullwidth-code-point": "^3.0.0",
    "is-npm": "^1.0.0",
    "is-redirect": "^1.0.0",
    "is-stream": "^1.1.0",
    "is-typedarray": "^1.0.0",
    "isarray": "^1.0.0",
    "isexe": "^2.0.0",
    "isstream": "^0.1.2",
    "js-yaml": "^3.14.1",
    "jsbn": "^0.1.1",
    "json-schema": "^0.4.0",
    "json-schema-traverse": "^0.4.1",
    "json-stringify-safe": "^5.0.1",
    "jsprim": "^1.4.2",
    "latest-version": "^1.0.1",
    "lodash": "^3.10.1",
    "lowercase-keys": "^1.0.1",
    "lru-cache": "^2.7.3",
    "mime-db": "^1.52.0",
    "mime-types": "^2.1.35",
    "minimatch": "^2.0.10",
    "minimist": "^1.2.8",
    "mkdirp": "^0.5.6",
    "mute-stream": "^0.0.4",
    "natives": "^1.1.6",
    "nested-error-stacks": "^1.0.2",
    "nopt": "^3.0.6",
    "normalize-package-data": "^2.5.0",
    "npm-package-arg": "^4.2.1",
    "npm-registry-client": "^6.5.1",
    "npmconf": "^2.1.3",
    "npmlog": "^7.0.1",
    "oauth-sign": "^0.9.0",
    "object-assign": "^2.1.1",
    "once": "^1.4.0",
    "optimist": "^0.6.1",
    "os-homedir": "^1.0.2",
    "os-tmpdir": "^1.0.2",
    "osenv": "^0.1.5",
    "package-json": "^1.2.0",
    "path-is-absolute": "^1.0.1",
    "path-parse": "^1.0.7",
    "performance-now": "^2.1.0",
    "pinkie": "^2.0.4",
    "pinkie-promise": "^2.0.1",
    "prepend-http": "^1.0.4",
    "process-nextick-args": "^2.0.1",
    "proto-list": "^1.2.4",
    "psl": "^1.9.0",
    "punycode": "^2.3.1",
    "q": "^1.5.1",
    "qs": "^6.5.3",
    "rc": "^1.2.8",
    "read-all-stream": "^3.1.0",
    "readable-stream": "^2.3.8",
    "readline2": "^0.1.1",
    "registry-url": "^3.1.0",
    "request": "^2.88.2",
    "resolve": "^1.22.8",
    "retry": "^0.6.1",
    "rimraf": "^2.7.1",
    "rx": "^2.5.3",
    "safe-buffer": "^5.2.1",
    "safer-buffer": "^2.1.2",
    "semver": "^4.3.6",
    "semver-diff": "^2.1.0",
    "set-blocking": "^2.0.0",
    "signal-exit": "^4.1.0",
    "slide": "^1.1.6",
    "spdx-correct": "^3.2.0",
    "spdx-exceptions": "^2.5.0",
    "spdx-expression-parse": "^3.0.1",
    "spdx-license-ids": "^3.0.20",
    "sprintf-js": "^1.0.3",
    "sshpk": "^1.18.0",
    "stream-shift": "^1.0.3",
    "string-length": "^1.0.1",
    "string-width": "^4.2.3",
    "string_decoder": "^1.1.1",
    "strip-ansi": "^3.0.1",
    "strip-json-comments": "^2.0.1",
    "supports-color": "^2.0.0",
    "supports-preserve-symlinks-flag": "^1.0.0",
    "text-table": "^0.2.0",
    "through": "^2.3.8",
    "timed-out": "^2.0.0",
    "tough-cookie": "^2.5.0",
    "tunnel-agent": "^0.6.0",
    "tweetnacl": "^0.14.5",
    "typedarray": "^0.0.6",
    "uid-number": "^0.0.5",
    "update-notifier": "^0.3.2",
    "uri-js": "^4.4.1",
    "user-home": "^1.1.1",
    "util-deprecate": "^1.0.2",
    "uuid": "^3.4.0",
    "validate-npm-package-license": "^3.0.4",
    "verror": "^1.10.0",
    "walkdir": "^0.0.7",
    "which": "^1.3.1",
    "wide-align": "^1.1.5",
    "wordwrap": "^0.0.3",
    "wrappy": "^1.0.2",
    "xdg-basedir": "^1.0.1"
  }
}

我认为我没有安装

gulp
,但不确定如何确认。

编辑:package-lock.json 内容我发现了 19 个

graceful-fs
的实例 下

packages: {
        ...
        "graceful-fs": "^3.0.0",


    "node_modules/@pnpm/network.ca-file": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/@pnpm/network.ca-file/-/network.ca-file-1.0.2.tgz",
      "integrity": "sha512-YcPQ8a0jwYU9bTdJDpXjMi7Brhkr1mXsXrUJvjqM2mQDgkRiz8jFaQGOdaLxgjtUfQgZhKy/O3cG/YwmgKaxLA==",
      "license": "MIT",
      "dependencies": {
        "graceful-fs": "4.2.10"
      },
      "engines": {
        "node": ">=12.22.0"
      }
    },

    "node_modules/@pnpm/network.ca-file/node_modules/graceful-fs": {
      "version": "4.2.10",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
      "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
      "license": "ISC"
    },

    "node_modules/configstore": {
      "version": "0.3.2",
      "resolved": "https://registry.npmjs.org/configstore/-/configstore-0.3.2.tgz",
      "integrity": "sha512-2aMMi3erDQwgL7BgnW0aIzILAikpVH4TVEz60F/naT+XsPPX6IaPEuF/zD28XSNFWO/mHQ9OVRxkvcSbq6EFdA==",
      "license": "BSD",
      "dependencies": {
        "graceful-fs": "^3.0.1",
        "js-yaml": "^3.1.0",
        "mkdirp": "^0.5.0",
        "object-assign": "^2.0.0",
        "osenv": "^0.1.0",
        "user-home": "^1.0.0",
        "uuid": "^2.0.1",
        "xdg-basedir": "^1.0.0"
      },
      "engines": {
        "node": ">=0.10.0"
      }
    },

    "node_modules/graceful-fs": {
      "version": "3.0.12",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.12.tgz",
      "integrity": "sha512-J55gaCS4iTTJfTXIxSVw3EMQckcqkpdRv3IR7gu6sq0+tbC363Zx6KH/SEwXASK9JRbhyZmVjJEVJIOxYsB3Qg==",
      "license": "ISC",
      "dependencies": {
        "natives": "^1.1.3"
      },
      "engines": {
        "node": ">=0.4.0"
      }
    },

    "node_modules/natives": {
      "version": "1.1.6",
      "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
      "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==",
      "deprecated": "This module relies on Node.js's internals and will break at some point. Do not use it, and update to [email protected].",
      "license": "ISC"
    },

    "node_modules/npm-check/node_modules/npm-registry-client": {
      "version": "6.5.1",
      "resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-6.5.1.tgz",
      "integrity": "sha512-tl3K50MxyX3vuHhlKVOEV2SLurqO21vSap1dtw0X42VkO6rKPZi0SF0U5mkIMXRfmRur7xoCVqF2xNOcjO2lfQ==",
      "deprecated": "This package is no longer supported.",
      "dev": true,
      "license": "ISC",
      "dependencies": {
        "chownr": "0",
        "concat-stream": "^1.4.6",
        "graceful-fs": "^3.0.0",
        "mkdirp": "^0.5.0",
        "normalize-package-data": "~1.0.1 || ^2.0.0",
        "npm-package-arg": "^3.0.0 || ^4.0.0",
        "once": "^1.3.0",
        "request": "^2.47.0",
        "retry": "^0.6.1",
        "rimraf": "2",
        "semver": "2 >=2.2.1 || 3.x || 4 || 5",
        "slide": "^1.1.3"
      },
      "optionalDependencies": {
        "npmlog": ""
      }
    },

    "node_modules/npm-registry-client": {
      "version": "8.6.0",
      "resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-8.6.0.tgz",
      "integrity": "sha512-Qs6P6nnopig+Y8gbzpeN/dkt+n7IyVd8f45NTMotGk6Qo7GfBmzwYx6jRLoOOgKiMnaQfYxsuyQlD8Mc3guBhg==",
      "deprecated": "This package is no longer supported.",
      "license": "ISC",
      "dependencies": {
        "concat-stream": "^1.5.2",
        "graceful-fs": "^4.1.6",
        "normalize-package-data": "~1.0.1 || ^2.0.0",
        "npm-package-arg": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
        "once": "^1.3.3",
        "request": "^2.74.0",
        "retry": "^0.10.0",
        "safe-buffer": "^5.1.1",
        "semver": "2 >=2.2.1 || 3.x || 4 || 5",
        "slide": "^1.1.3",
        "ssri": "^5.2.4"
      },
      "optionalDependencies": {
        "npmlog": "2 || ^3.1.0 || ^4.0.0"
      }
    },

    "node_modules/npm-registry-client/node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },

    "node_modules/update-notifier/node_modules/configstore": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/configstore/-/configstore-7.0.0.tgz",
      "integrity": "sha512-yk7/5PN5im4qwz0WFZW3PXnzHgPu9mX29Y8uZ3aefe2lBPC1FYttWZRcaW9fKkT0pBCJyuQ2HfbmPVaODi9jcQ==",
      "license": "BSD-2-Clause",
      "dependencies": {
        "atomically": "^2.0.3",
        "dot-prop": "^9.0.0",
        "graceful-fs": "^4.2.11",
        "xdg-basedir": "^5.1.0"
      },
      "engines": {
        "node": ">=18"
      },
      "funding": {
        "url": "https://github.com/yeoman/configstore?sponsor=1"
      }
    },
    "node_modules/update-notifier/node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },


}
node.js npm nvm
1个回答
0
投票

好的。在寻找合适的解决方案时,我遇到了这个网站

我首先使用以下命令检查过时的软件包:

npm outdated

然后安装网站上提到的工具:

npm install -g npm-check-updates

尝试过

npm update
,但无法更新。

然后终于尝试了

ncu -u
,它在更新我的包后更新了我的package.json。不再有错误! :)

© www.soinside.com 2019 - 2024. All rights reserved.