Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve this error: "internal/modules/cjs/loader.js:638 throw err; ^"

I want to run my Vue.js using npm on localhost:8080 but they give me this error. Is there a way to solve this issue?

This error only occurs when I tried to install node_modules and package-lock.json in my Vue folder containing .babelrc, package.json and webpack.config.js. For my other Vue folders, I still can run my localhost:8080 by using the same method for all folders which is

npm install

npm run dev

The code below is the Error.

The system cannot find the path specified.
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'C:\Users\acer\Documents\VueJs\cross-env\dist\bin\cross-env.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-cli@ dev: `cross-env NODE_ENV=development webpack-dev-server --open --inline --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-cli@ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\acer\AppData\Roaming\npm-cache\_logs\2019-08-23T06_50_37_455Z-debug.log
like image 305
Hariz Tay Avatar asked Aug 23 '19 07:08

Hariz Tay


2 Answers

Before you go uninstalling everything, try closing the terminal and trying again in a new Terminal instance

like image 178
CodyBugstein Avatar answered Oct 17 '22 23:10

CodyBugstein


I had a similar issue which I solved by noticing that when I followed the advice here: https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1056#issuecomment-699456515 and proceeded to run npm run build which is what was giving me that error, it would work inside of the newly created project with vue create <project-name>. I had my code in a repository so I recloned it, copied the node_modules folder into my working directory and then ran it again and it worked.

like image 20
Jacob Anderson Avatar answered Oct 17 '22 22:10

Jacob Anderson