npm install -g yo command gives -> ERR! yo@1.1.0 postinstall: `node scripts/doctor.js`

前端 未结 7 555
醉梦人生
醉梦人生 2020-12-31 04:38

I just tried to do a npm install but get this error about doctor,js at the end. Do I need to worry about it?

npm install -g yo

. .



        
相关标签:
7条回答
  • 2020-12-31 04:46

    To solve this problem you need to install the package nodejs-legacy.

    sudo apt-get install nodejs-legacy
    
    0 讨论(0)
  • 2020-12-31 04:49

    I believe this may be due to the way which node was installed on your system. Apparently, sometimes when installing Node via a package manager, the linked binary is nodejs, (thus nodejs _command_ is the command that works on your machine, not the much more common node _comamand_. You can either re-install Node (the latest version is now 0.10.24) from nodejs.org, or try this solution from this related issue:

    For anyone wishing to still use their OS's package of node the simple solution for this is to determine where node is installed on your OS and then create a symbolic link.

    For example I had the issue on ubuntu and the install directory is /usr/bin. To create the symlink you can run:

    sudo ln -s /usr/bin/nodejs /usr/bin/node

    in windows you can use the mklink command.. Be sure to open the command prompt as a administrator

    0 讨论(0)
  • 2020-12-31 05:01

    On Ubuntu 14.04, I tried both installing the legacy package (per Antonio's answer) and creating the symlink manually (per Stephen's answer). Neither worked. The Ubuntu package has version 0.10.25 of node.js, but Yeoman seems to require a newer version.

    After installing the latest version of node.js from NodeSource (currently v6.9.1), I was able to install Yeoman using npm install -g yo .

    0 讨论(0)
  • 2020-12-31 05:04

    Likewise I had this same problem (albeit on a Mac). I uninstalled and upgraded node to the latest version (v0.10.24) but without success.

    The symlink fix did work for me, although with a slight tweak:

    sudo ln -s /usr/local/bin/node /usr/bin/node

    0 讨论(0)
  • 2020-12-31 05:05

    You have to install nodejs in this way:

    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs
    
    0 讨论(0)
  • 2020-12-31 05:08

    I had this same error on a clean Ubuntu 13.10 install and no amount of sym linking (node > nodejs) or installing/uninstalling helped me.

    I don't have a deep enough understanding of the node environment to troubleshoot it properly but I was able to install Yeoman globally by cloning the repo and removing the postinstall check from package.json.

    If anyone else want's to try this solution:

    Clone Yeoman..

    cd ~
    git clone https://github.com/yeoman/yo
    

    Edit the package.json..

    nano yo/package.json
    

    .. to remove these lines..

    "scripts": {
        "test": "grunt",
        "postinstall": "node ./scripts/doctor",
        "postupdate": "node ./scripts/doctor"
    },
    

    Then, install it using npm..

    cd yo
    npm install -g
    

    If you want to clean up you can remove the Yeoman repo..

    cd ..
    rm -R yo/
    

    Obviously your mileage may vary but it's working fine for me so far.

    I also noticed I was able to successfully run the doctor.js script independent of the installation process. No idea why it was failing so hard in the first place..

    0 讨论(0)
提交回复
热议问题