Install for @angular/cli not working on Mac

前端 未结 1 1416
醉话见心
醉话见心 2020-12-19 08:53

I\'m trying to setup Angular 2 using \"npm install @angular/cli -g \"

After the install, the only warning I see is the UNMET PEER DEPENDENCY rxjs@^5.0.1, which I th

相关标签:
1条回答
  • 2020-12-19 09:40

    Most likely, the directory in which the global modules are installed is not in your $PATH -- and therefore unknown to your shell.

    To fix this issue, we can create a new directory for global node_modules, configure npm to use it, and add that directory to your $PATH.

    # create a new directory where npm will install packages
    $  mkdir ~/.node_modules
    
    # set npm "prefix" config to that directory
    $  npm config set prefix '~/.node_modules'
    
    # append a line to your .zshrc instructing it to include that directory in your $PATH, making the executables known to the shell
    $ echo 'export PATH=~/.node_modules/bin:$PATH' >> ~/.zshrc
    
    # update current shell with new path (not needed for new sessions)
    $ source ~/.zshrc
    

    Then, first reinstall the latest npm (npm i -g npm), followed by the global packages you need (npm i -g @angular/cli).

    For more on PATH, see this definition: http://www.linfo.org/path_env_var.html

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