DEV Community

Muhammad
Muhammad

Posted on

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

Short answer:-

Yes

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)