DEV Community


Posted on

Can I install a dependency as devDependency instead of as a global dependency and still use it?

Short answer:-


Long answer:-

Yes, you can install a dependency as a devDependency (e.g. npm install -D nodemon) instead of installing it globally (e.g. npm install -g nodemon) and you can still use it inside your project.

However you cannot use it directly (e.g. by typing nodemon index.js in the Terminal)

You must create a script and then run the script to use it. (e.g. in package.json, you add "start":"nodemon index.js" and then you are free to use nodemon as with a global install by running npm start in the Terminal)

Top comments (0)

Why You Need to Study Javascript Fundamentals

The harsh reality for JS Developers: If you don't study the fundamentals, you'll be just another β€œCoder”. Top learnings on how to get to the mid/senior level faster as a JavaScript developer by Dragos Nedelcu.