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

时间:2014-09-27 07:13:37

标签: javascript node.js installation npm homebrew

我正在尝试安装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

我知道它说它有效......我只是想找出错误信息的含义。并看看我能做些什么来解决它。

有什么想法吗?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

虽然看起来你把这一切都整理好了,但我想回答这个问题来提出这个&#34;官方&#34; (支持npm)在OSX上安装npm的方式:

  • 请勿使用brew;
  • 安装&#34;官方&#34;来自https://nodejs.org/download
  • 的节点二进制文件
  • 安装最新的npmsudo npm install -g npm@latest

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