WebStorm starts the vue project and reports an error, error code: 1080 throw err
error code
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module '../package.json'
Require stack:
- /Users/mike/WebstormProjects/vue-qms/node_modules/.bin/vue-cli-service
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:121:18)
at Object.<anonymous> (/Users/mike/WebstormProjects/vue-qms/node_modules/.bin/vue-cli-service:4:25)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/mike/WebstormProjects/vue-qms/node_modules/.bin/vue-cli-service'
]
}
Node.js v18.17.1
Solution
This error indicates that Node.js vue-cli-service
was unable to find the associated module or file when trying to execute . Usually this is because some dependencies are missing or incorrectly configured.
Please try the following steps to resolve this issue:
-
Reinstall dependencies: Go to your Vue project directory, delete
node_modules
the folder, and reinstall dependencies:rm -rf node_modules npm install
-
Check package.json: Make sure you have a valid
package.json
file in your project directory. If not, you can generate a newpackage.json
file with:npm init -y
-
Install Vue CLI: If you don't have Vue CLI installed, you can try installing it locally in your project directory:
npm install @vue/cli
-
Try using yarn: If you
npm
're having trouble with using , you can also try usingyarn
to manage dependencies. First make sure you have it installed globallyyarn
, then run the following command in the project directory:yarn install
-
Update Node.js version: If the problem persists, consider upgrading or downgrading your Node.js version, as some versions of Node.js may not be compatible with certain dependencies.
-
Check the file path: Make sure you are running the command in the correct project directory and there are no typos or other issues in the path.
If you have tried the above steps but the problem persists, please provide more information about your project structure, operation steps and error log, so that I can further help you to solve the problem.
PS: Make sure that the computer has installed nodejs-https://nodejs.org/en before executing