How to transfer package from devDependencies to dependencies in package.json

I’m wondering if there’s a quick way to transfer a package from devDependencies to dependencies in my package.json file.

Right now I keep doing this process:

npm remove express --save-dev
npm add express --save

This feels like too many steps for something that should be simple. Is there a more efficient way to move packages between these sections? Maybe a single command that can handle this transfer without having to uninstall and reinstall?

I work with npm regularly and this situation comes up often when I realize a dev dependency actually needs to be a production dependency.

Here’s a cleaner trick: just run npm install express --save even if the package is already in devDependencies. Npm automatically moves it to dependencies and removes it from devDependencies for you. Way better than editing package.json manually since you can’t mess up the syntax, and it handles version conflicts too. I stumbled on this when I forgot a package was already installed as a dev dependency - the command worked perfectly and moved everything over. Much easier than your current remove-then-add approach.

Honestly, npm mv would be perfect here but it doesn’t exist lol. You could switch to yarn - yarn add express automatically moves packages from dev to prod dependencies. If you’re stuck with npm though, I’d just edit package.json directly since it saves network calls.

You can just edit package.json directly and run npm install after. Cut the package line from devDependencies, paste it into dependencies, then run npm install. This updates package-lock.json correctly and it’s way faster than removing and re-adding packages. I’ve done this for years without problems. Just don’t forget the npm install step - that’s what updates the lock file with the new dependency tree. Works great and saves tons of time when moving multiple packages.