DEV Community

Cover image for TIL: 2021-09-20 -  Automatically update package.json dependencies
Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on • Updated on

TIL: 2021-09-20 - Automatically update package.json dependencies

How to automatically update npm packages versions


During chore update of my vue-ts template dependencies (to learn more about it, read here) I was doing usual npm "upgrade" steps.

  1. Run npm update to automatically update my packages to the latest versions From docs: > This command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).
  2. Run npm outdated - to see what could be still updated.

npm update - only updates package-lock.json and does not change package.json. I started searching for a way to automatically update my dependencies in package.json file as well.


Quick searching pointed me to this stackoverflow post, where one of the answers suggested using npm-check-updates tool.

  1. npm -g install npm-check-updates
  2. ncu to see outdated versions or ncu --upgrade to update the package.json.


Fix TS2307: Cannot find module 'src' or its corresponding type declarations.


After I updated my package.json and installed all dependencies, my npm run build started failing with

$ npm run build

> vite-vue-typescript-starter@0.0.0 build
> vue-tsc --noEmit && vite build

node_modules/@vue/test-utils/dist/domWrapper.d.ts:5:28 - error TS2307: Cannot find module 'src' or its corresponding type declarations.

5 import { VueWrapper } from 'src';

Found 1 error.
Enter fullscreen mode Exit fullscreen mode


This was a tricky one because at a first glance it may seem that I have a typescript problem in project which is technically correct, but actually this is a bug in @vue/test-utils-next library which was introduced in 2.0.0-rc.14 version. Installing 2.0.0-rc.13 or setting skipLibCheck: true in tsconfig.json solves this. For my case I've chosen the first approach.


  1. skipLibCheck: true > Skip type checking of declaration files.


Discussion (0)