Vue Cli: Cannot find module '../package.json' error after npm install

Jenos picture Jenos · Jan 27, 2019 · Viewed 12.8k times · Source

I am not an expert in Vuejs or Vuecli, but I do manage to get stuff working. I had a project i worked on before using Vuecli3 and webpack and now when I opened it after few weeks to make changes, i get the below error in dev mode

Total task duration: 0.15s

The package.json file is right there in the root director and also the .lock file. Dont know what is the reason for this error in compiling.

Any help hightly appreciated

Answer

amucunguzi picture amucunguzi · May 8, 2019

As @vesperknight mentioned in the comment, this issue tends to happen when you move the project's folder to another location.

To solve this (on Linux), from the root directory of your project:

  1. Delete existing node modules. rm -r node_modules

  2. Reinstall all dependencies: npm install

The first step seems to be important.