【发布时间】: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 非常不熟悉,如果我做了任何错误的假设,请见谅。
【问题讨论】:
-
查看此链接也许这会有所帮助,newline.co/@Adele/…
标签: node.js macos npm macos-monterey