TypeError:无法读取未定义的属性“node”

nlejzf6q  于 2023-02-12  发布在  Node.js
关注(0)|答案(1)|浏览(169)

我正在尝试安装NPM。
我第一次跑
brew install node
那么

curl -O https://www.npmjs.org/install.sh

那么

~ % sh install.sh

这就是我得到的

tar=/usr/bin/tar
    version:
    bsdtar 2.8.3 - libarchive 2.8.3
    install npm@latest
    fetching: http://registry.npmjs.org/npm/-/npm-2.0.2.tgz

    /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:18
          val = val[f]
                   ^
    TypeError: Cannot read property 'node' of undefined
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:18:16
        at Array.forEach (native)
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:17:11
        at Array.forEach (native)
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:14:22
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:51:40
        at final (/private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:349:17)
        at then (/private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:126:33)
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:266:40
        at evalmachine.<anonymous>:271:14
    0.10.32

    /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:18
          val = val[f]
                   ^
    TypeError: Cannot read property 'node' of undefined
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:18:16
        at Array.forEach (native)
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:17:11
        at Array.forEach (native)
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/bin/read-package-json.js:14:22
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:51:40
        at final (/private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:349:17)
        at then (/private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:126:33)
        at /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package/node_modules/read-package-json/read-json.js:266:40
        at evalmachine.<anonymous>:271:14

    > npm@2.0.2 prepublish /private/var/folders/92/2l_j234x7n7bys14466b4dcr0000gn/T/npm.12852/package
    > node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test/*/*/node_modules && make -j8 doc

    make: Nothing to be done for `doc'.
    /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
    npm@2.0.2 /usr/local/lib/node_modules/npm
    It worked

我知道它说它工作...我只是想找出错误信息的意思。看看我能做些什么来修复它。
有什么想法吗?
谢谢你的帮助!

g2ieeal7

g2ieeal71#

虽然看起来你已经把这些都整理好了,但我还是想回答这个问题,提出在OSX上安装npm的“官方”(支持npm)方式:

  • 不要使用brew;
  • https://nodejs.org/download安装“正式”节点二进制文件
  • 安装最新的npmsudo npm install -g npm@latest

如果以这种方式安装,则更容易在npm问题跟踪器https://github.com/npm/npm上获得支持

相关问题