Search code examples
node.jsnpmprettiernvmnpx

prettier command not working even though prettier is in devDependancies


In my package.json


 "devDependencies": {
   ...
   "prettier": "^2.8.4",
   ...
}

I run npm i.

Then:

$ prettier 
bash: prettier: command not found
$ npx prettier -v

/var/folders/q6/npwl_7xj4wg91lg06f8pnnfh0000gn/T/npx-b98a4fce.sh: line 1: prettier: command not found

Not sure if this- /var/folders/q6/npwl_7xj4wg91lg06f8pnnfh0000gn/T/npx-b98a4fce.sh- is normal.

I am using nvm, using node v16.17.1 and npm v8.15.0

Any ideas why this is happening or how to debug it?

EDIT: prettier worked after I npm install -g prettier to install prettier globally. But shouldn't it work without this?


Solution

  • After trying a bunch of things, I noticed it only affected this one folder. So what finally worked was simply cloning the repo again into a different folder.