【问题标题】:Can't use npm on MacOS Monterey 12.0.1无法在 MacOS Monterey 12.0.1 上使用 npm
【发布时间】:2022-01-15 09:34:37
【问题描述】:

当我尝试在终端中以任何方式使用 npm 时,它会引发错误。

You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/Users/USERNAME/.nvm/versions/node/v10.15.3/lib/node_modules/npm/lib/npm.js:32
  #unloaded = false
  ^

SyntaxError: Invalid or unexpected token
    at new Script (vm.js:80:7)
    at createScript (vm.js:274:10)
    at Object.runInThisContext (vm.js:326:10)
    at Module._compile (internal/modules/cjs/loader.js:664:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)

谷歌搜索后我遇到了这个问题:npm does not support Node.js v10.19.0 这似乎解决了 linux 上的问题。也许有一种方法可以将该解决方案转换为适用于 MacOS 的解决方案,但不幸的是我不知道如何。

即使在 https://nodejs.org/ 上更新 Node.js 后,我仍然收到与上述完全相同的错误。

我有预感这是更新到 Monterey 后与 xcode 相关的一些问题引起的,但可能是错误的。

我对 npm 和 node.js 非常不熟悉,如果我做了任何错误的假设,请见谅。

【问题讨论】:

标签: node.js macos npm macos-monterey


【解决方案1】:

尝试使用 NVM 安装和管理您的 Node 版本。在 Mac 上运行良好。 https://www.linode.com/docs/guides/how-to-install-use-node-version-manager-nvm/

【讨论】:

    猜你喜欢
    • 2022-01-17
    • 2021-12-12
    • 2021-12-12
    • 2022-08-16
    • 2021-12-15
    • 2022-12-04
    • 2021-12-12
    • 2021-12-15
    • 2021-10-08
    相关资源
    最近更新 更多