how resolve “sudo npm install” issues on MacOS The Next CEO of Stack OverflowHow to check for an active Internet connection on iOS or macOS?How does the vim “write with sudo” trick work?Where does npm install packages?How can I update NodeJS and NPM to the next versions?Find the version of an installed npm packageHow to uninstall npm modules in node js?npm throws error without sudoHow do I install pip on macOS or OS X?How to install an npm package from GitHub directly?What is the --save option for npm install?

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Do I need to enable Dev Hub in my PROD Org?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

What happened in Rome, when the western empire "fell"?

How to add tiny 0.5A 120V load to very remote split phase 240v 3 wire well house

Between two walls

What's the best way to handle refactoring a big file?

Is HostGator storing my password in plaintext?

Has this building technique been used in an official set?

How do I transpose the 1st and -1th levels of an arbitrarily nested array?

Should I tutor a student who I know has cheated on their homework?

Which tube will fit a -(700 x 25c) wheel?

If the heap is initialized for security, then why is the stack uninitialized?

calculus parametric curve length

What exact does MIB represent in SNMP? How is it different from OID?

What flight has the highest ratio of time difference to flight time?

If/When UK leaves the EU, can a future goverment conduct a referendum to join the EU?

Received an invoice from my ex-employer billing me for training; how to handle?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Why didn't Khan get resurrected in the Genesis Explosion?

Indicator light circuit

Why do we use the plural of movies in this phrase "We went to the movies last night."?

In excess I'm lethal

What does "Its cash flow is deeply negative" mean?



how resolve “sudo npm install” issues on MacOS



The Next CEO of Stack OverflowHow to check for an active Internet connection on iOS or macOS?How does the vim “write with sudo” trick work?Where does npm install packages?How can I update NodeJS and NPM to the next versions?Find the version of an installed npm packageHow to uninstall npm modules in node js?npm throws error without sudoHow do I install pip on macOS or OS X?How to install an npm package from GitHub directly?What is the --save option for npm install?










2















Some time ago i've tried to update npm using sudo npm install on my Mac,
so the update didn't work and now i can't Run any of my npm progects.
after this problem i tried to solve it search some answers on npm forum, and i've found a discussion where a developer said "never use sudo npm install, in particular on MacOS".
so my question is



  1. how can i fix this problem without Formatting my pc if possible

  2. why using sudo with npm command is a bad idea ?


I'm sorry for my bad english, but i try hard to do my best.
thanks for your patience.










share|improve this question


























    2















    Some time ago i've tried to update npm using sudo npm install on my Mac,
    so the update didn't work and now i can't Run any of my npm progects.
    after this problem i tried to solve it search some answers on npm forum, and i've found a discussion where a developer said "never use sudo npm install, in particular on MacOS".
    so my question is



    1. how can i fix this problem without Formatting my pc if possible

    2. why using sudo with npm command is a bad idea ?


    I'm sorry for my bad english, but i try hard to do my best.
    thanks for your patience.










    share|improve this question
























      2












      2








      2


      0






      Some time ago i've tried to update npm using sudo npm install on my Mac,
      so the update didn't work and now i can't Run any of my npm progects.
      after this problem i tried to solve it search some answers on npm forum, and i've found a discussion where a developer said "never use sudo npm install, in particular on MacOS".
      so my question is



      1. how can i fix this problem without Formatting my pc if possible

      2. why using sudo with npm command is a bad idea ?


      I'm sorry for my bad english, but i try hard to do my best.
      thanks for your patience.










      share|improve this question














      Some time ago i've tried to update npm using sudo npm install on my Mac,
      so the update didn't work and now i can't Run any of my npm progects.
      after this problem i tried to solve it search some answers on npm forum, and i've found a discussion where a developer said "never use sudo npm install, in particular on MacOS".
      so my question is



      1. how can i fix this problem without Formatting my pc if possible

      2. why using sudo with npm command is a bad idea ?


      I'm sorry for my bad english, but i try hard to do my best.
      thanks for your patience.







      node.js macos npm install sudo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 15:21









      BistoXBistoX

      132




      132






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I wrote an article about this issue that also walks through some solutions to managing node/npm versions without using sudo: https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92



          I'll try to summarize here.



          First of all, if you're using MacOS, I highly recommend using homebrew to install system node if you haven't done so already. You should be able to run brew install node (which will also install npm and yarn) without using sudo assuming you've gone through the homebrew setup properly.



          If you want to manage multiple versions of Node, I highly recommend https://github.com/tj/n as a tool. nvm is also very popular, but I prefer n. I walk through how to install and manage n in my article, but someone has also created a tool to help you through this: https://github.com/mklement0/n-install.



          You can also take a look at this part of my 2015 article on the same topic to potentially help you with issues you might face from having run sudo npm install in the past. You might try sudo rm -rf node_modules in your project followed by npm install (without sudo).



          Similarly, you may have to do something akin to sudo rm -rf $(npm prefix -g)/bin,lib/node_modules in case you globally installed node modules with the wrong prefix. Just be aware that this will remove libraries you installed with sudo before, so you will have to install them again.



          In addition to the issues you're running into, a key reason why you shouldn't use sudo npm anything is because npm commands including install have the ability to run arbitrary scripts including ones that are downloaded from the registry. You don't want to give root permissions to something that runs arbitrary scripts!






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047241%2fhow-resolve-sudo-npm-install-issues-on-macos%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I wrote an article about this issue that also walks through some solutions to managing node/npm versions without using sudo: https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92



            I'll try to summarize here.



            First of all, if you're using MacOS, I highly recommend using homebrew to install system node if you haven't done so already. You should be able to run brew install node (which will also install npm and yarn) without using sudo assuming you've gone through the homebrew setup properly.



            If you want to manage multiple versions of Node, I highly recommend https://github.com/tj/n as a tool. nvm is also very popular, but I prefer n. I walk through how to install and manage n in my article, but someone has also created a tool to help you through this: https://github.com/mklement0/n-install.



            You can also take a look at this part of my 2015 article on the same topic to potentially help you with issues you might face from having run sudo npm install in the past. You might try sudo rm -rf node_modules in your project followed by npm install (without sudo).



            Similarly, you may have to do something akin to sudo rm -rf $(npm prefix -g)/bin,lib/node_modules in case you globally installed node modules with the wrong prefix. Just be aware that this will remove libraries you installed with sudo before, so you will have to install them again.



            In addition to the issues you're running into, a key reason why you shouldn't use sudo npm anything is because npm commands including install have the ability to run arbitrary scripts including ones that are downloaded from the registry. You don't want to give root permissions to something that runs arbitrary scripts!






            share|improve this answer



























              0














              I wrote an article about this issue that also walks through some solutions to managing node/npm versions without using sudo: https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92



              I'll try to summarize here.



              First of all, if you're using MacOS, I highly recommend using homebrew to install system node if you haven't done so already. You should be able to run brew install node (which will also install npm and yarn) without using sudo assuming you've gone through the homebrew setup properly.



              If you want to manage multiple versions of Node, I highly recommend https://github.com/tj/n as a tool. nvm is also very popular, but I prefer n. I walk through how to install and manage n in my article, but someone has also created a tool to help you through this: https://github.com/mklement0/n-install.



              You can also take a look at this part of my 2015 article on the same topic to potentially help you with issues you might face from having run sudo npm install in the past. You might try sudo rm -rf node_modules in your project followed by npm install (without sudo).



              Similarly, you may have to do something akin to sudo rm -rf $(npm prefix -g)/bin,lib/node_modules in case you globally installed node modules with the wrong prefix. Just be aware that this will remove libraries you installed with sudo before, so you will have to install them again.



              In addition to the issues you're running into, a key reason why you shouldn't use sudo npm anything is because npm commands including install have the ability to run arbitrary scripts including ones that are downloaded from the registry. You don't want to give root permissions to something that runs arbitrary scripts!






              share|improve this answer

























                0












                0








                0







                I wrote an article about this issue that also walks through some solutions to managing node/npm versions without using sudo: https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92



                I'll try to summarize here.



                First of all, if you're using MacOS, I highly recommend using homebrew to install system node if you haven't done so already. You should be able to run brew install node (which will also install npm and yarn) without using sudo assuming you've gone through the homebrew setup properly.



                If you want to manage multiple versions of Node, I highly recommend https://github.com/tj/n as a tool. nvm is also very popular, but I prefer n. I walk through how to install and manage n in my article, but someone has also created a tool to help you through this: https://github.com/mklement0/n-install.



                You can also take a look at this part of my 2015 article on the same topic to potentially help you with issues you might face from having run sudo npm install in the past. You might try sudo rm -rf node_modules in your project followed by npm install (without sudo).



                Similarly, you may have to do something akin to sudo rm -rf $(npm prefix -g)/bin,lib/node_modules in case you globally installed node modules with the wrong prefix. Just be aware that this will remove libraries you installed with sudo before, so you will have to install them again.



                In addition to the issues you're running into, a key reason why you shouldn't use sudo npm anything is because npm commands including install have the ability to run arbitrary scripts including ones that are downloaded from the registry. You don't want to give root permissions to something that runs arbitrary scripts!






                share|improve this answer













                I wrote an article about this issue that also walks through some solutions to managing node/npm versions without using sudo: https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92



                I'll try to summarize here.



                First of all, if you're using MacOS, I highly recommend using homebrew to install system node if you haven't done so already. You should be able to run brew install node (which will also install npm and yarn) without using sudo assuming you've gone through the homebrew setup properly.



                If you want to manage multiple versions of Node, I highly recommend https://github.com/tj/n as a tool. nvm is also very popular, but I prefer n. I walk through how to install and manage n in my article, but someone has also created a tool to help you through this: https://github.com/mklement0/n-install.



                You can also take a look at this part of my 2015 article on the same topic to potentially help you with issues you might face from having run sudo npm install in the past. You might try sudo rm -rf node_modules in your project followed by npm install (without sudo).



                Similarly, you may have to do something akin to sudo rm -rf $(npm prefix -g)/bin,lib/node_modules in case you globally installed node modules with the wrong prefix. Just be aware that this will remove libraries you installed with sudo before, so you will have to install them again.



                In addition to the issues you're running into, a key reason why you shouldn't use sudo npm anything is because npm commands including install have the ability to run arbitrary scripts including ones that are downloaded from the registry. You don't want to give root permissions to something that runs arbitrary scripts!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 7 at 15:29









                Explosion PillsExplosion Pills

                151k38228317




                151k38228317





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047241%2fhow-resolve-sudo-npm-install-issues-on-macos%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                    Алба-Юлія

                    Захаров Федір Захарович