I cannot get NPM to install properly


(J$) #1

Hello - I cannot seem to get NPM to work on any directory of my system. Nothing but issues. I’m not sure how to resolve this at a global level.

(Lars Willighagen) #2

This all seems normal, expected behaviour, and on top of that non-fatal errors and warnings. What are you trying to do?

(J$) #3

trying to install formik into my project. I screwed up my bash somehow and can’t figure out how to fix it.

(Lars Willighagen) #4

To create a project, you need a directory with a package.json file. Then, to install formik you can run

npm install formik

in your project directory. To use formik, you also need to install react (that’s what the “UNMET PEER DEPENDENCY” warning is all about).

(J$) #5

I used create-react-app to initiate this project/app so react should be there

(Lars Willighagen) #6

The warning was emitted because formik was installed globally (that’s why it shows with npm list -g). If your local project already has react, installing formik locally should be enough.

(J$) #7

Ok. I thought installing it globally enabled whatever I installed to be accessed from anywhere.

(Lars Willighagen) #8

No, global mode is meant for executables:

  • Install it globally if you’re going to run it on the command line.


Installing it in your project also makes it easier to set up that project somewhere else. Then, all the dependencies are defined in package.json, instead of all over the place.

(J$) #9

I think it’s something larger than that. I think I mucked up my bash file and have no idea how to recover.

(Lars Willighagen) #10

I would try to re-install node.js (which should restore the npm command).

(J$) #11

ok. I’ll try that. Is there a way or me to ensure things are uninstalled everywhere? then reinstall?

(Lars Willighagen) #12

There’s a guide here.

(J$) #13

I just reinstalled node and I’m still not able to execute some commands.

(Lars Willighagen) #14

There seems to be a typo in some prefix config somewhere: .npm-globa. Or is that intentional?

(J$) #15

nope not intentional. Ok. how does one go about fixing that.

(Lars Willighagen) #16

What’s weird is that npm normally isn’t in that directory in Windows. Anyway, check

npm config get prefix

This probably gives the .npm-globa one. If it does, you can change it with

npm config set prefix '...'

You’d have to reinstall global packages (or move the directory .npm-globa to .npm-global, but that’s risky).

I’ll be back sometime tomorrow (it’s 12 AM here now)

(J$) #17

no worries. appreciate the assist.

(J$) #18

still can’t seem to upgrade.

(Stephanie ) #20

it is npm upgrade, not npm-upgrade (no dash between the two commands)

(Lars Willighagen) #21

Sorry for the confusion. I didn’t literally mean

npm config set prefix '...'

I meant replace the ... with whatever the prefix should be. So it would probably be

npm config set prefix /Users/jkidd/.npm-global

In this case, I think. However, that all depends on your PATH. You want the directory


to be on your path, specifically.