problem with laravel and vue.js | Error: Cannot find module - node.js

I recently got this error whenever I install vue in laravel using the following commands:
composer require laravel/UI
PHP artisan up vue
php artisan ui vue --auth
npm install && npm run dev
I get this new error and its the first time that happened to me:
Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin'
Require stack:
- C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\plugin-webpack5.js
- C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\plugin.js
- C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\index.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\src\components\Vue.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\src\components\ComponentRegistrar.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\src\Mix.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\setup\webpack.config.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack-cli\lib\webpack-cli.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack-cli\lib\bootstrap.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack-cli\bin\cli.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (C:\wamp64\www\projects\quizapp\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\plugin-webpack5.js:6:42)
at Module._compile (C:\wamp64\www\projects\quizapp\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\vue-loader\\lib\\plugin-webpack5.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\vue-loader\\lib\\plugin.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\vue-loader\\lib\\index.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\src\\components\\Vue.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\src\\components\\ComponentRegistrar.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\src\\Mix.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\setup\\webpack.config.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack\\bin\\webpack.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # watch: `mix watch`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # watch 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\zzzab\AppData\Roaming\npm-cache\_logs\2021-08-05T07_08_51_267Z-debug.log
and I tried to make a new laravel project and didn't work.

Finally, i have the solution,
1- Delete the node_modules folder using the file explorer and delete package-lock.json as well.
2- Run npm install command.
3- Run npm run dev or npm run watch for auto mix when ever change made.

Related

error when try to run npm build on react project

i'm trying to deploy my app via VPS (Ubuntu and Nginx) but this error keeps showing up, (on vs code it works fine) any idea how could i procede? thanks!
> mystery#0.1.0 build /home/react-projects/portfolio
> react-scripts build
/home/react-projects/portfolio/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
_ending;
^
SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/react-projects/portfolio/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mystery#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mystery#0.1.0 build 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! /root/.npm/_logs/2022-08-23T18_10_04_282Z-debug.log
one way you can :
go to your package.json
replace "react-scripts": "..." to "react-scripts": "1.1.4",
then run npm install, after that npm build
if it didn't work try :
create a file .env at the root of the folder react folder
type SKIP_PREFLIGHT_CHECK=true inside of .env file
this command will help you in resolving this npm error.
then try to run npm build and check it should work .
notice : this command will permanently disable this preflight check
Updating node to higher version worked for me, i was using v10.22.1: nvm use --lts
i solved it installing the correct versions through NVM on my web server
https://www.freecodecamp.org/news/how-to-install-node-js-on-ubuntu-and-update-npm-to-the-latest-version/

Keep getting missing module error when trying to do npm start

I keep getting the following error:
> kb-ui#0.0.1 start C:\Users\Tayeb\Desktop\F2f\bloomkonnect-fe
> webpack-dev-server --open --config webpack.dev.js --progress --watch
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'json-parse-better-errors'
Require stack:
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\webpack.js
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack\\lib\\Compiler.js',
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack\\lib\\webpack.js',
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! kb-ui#0.0.1 start: `webpack-dev-server --open --config webpack.dev.js --progress --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the kb-ui#0.0.1 start 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\Tayeb\AppData\Roaming\npm-cache\_logs\2021-06-23T17_23_33_473Z-debug.log
I have tried doing the following:
remove the node modules folder and run npm install
remove the node modules and package lock json and do npm install
re install node.js
delete the clone the repository again
I dont get what is wrong. When I look inside the node modules folder the module it is saying is missing is there. This is driving me nuts.

Express-getting this error message trying to run server

I'm trying to run the server on the back-end of a project I'm doing and I keep getting this error message and it stops the server from running. I installed express generator if that makes any difference
> server#0.0.0 start /Users/username/Desktop/project/server
> node ./bin/www
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'http-errors'
Require stack:
- /Users/username/Desktop/project/server/main/app.js
- /Users/username/Desktop/project/server/bin/www
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:747:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/username/Desktop/project/server/main/app.js:1:19)
at Module._compile (internal/modules/cjs/loader.js:1085:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:791:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/username/Desktop/project/server/main/app.js',
'/Users/username/Desktop/project/server/bin/www'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#0.0.0 start 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! /Users/username/.npm/_logs/2020-11-13T03_27_43_635Z-debug.log
It clearly says Error: Cannot find module 'http-errors', so you probably don't have the package installed locally. Run npm i http-errors to download it.
Alternatively, if you'd like to save the package as a dependency in your project, run npm i http-errors --save

Module not found (MODULE_NOT_FOUND) on nest.js code base

I have a code base which is working perfectly fine on a Windows box on node v10.16.3 but when I try to install the same code base on a CentOS Linux box with node v.12.16.3, I get the following error. Not sure what the issue could be.
# npm start
> nest start
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module '#angular-devkit/core'
Require stack:
- /usr/local/lib/node_modules/#nestjs/cli/lib/schematics/schematic.option.js
- /usr/local/lib/node_modules/#nestjs/cli/lib/schematics/index.js
- /usr/local/lib/node_modules/#nestjs/cli/actions/generate.action.js
- /usr/local/lib/node_modules/#nestjs/cli/actions/index.js
- /usr/local/lib/node_modules/#nestjs/cli/commands/command.loader.js
- /usr/local/lib/node_modules/#nestjs/cli/commands/index.js
- /usr/local/lib/node_modules/#nestjs/cli/bin/nest.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous>
(/usr/local/lib/node_modules/#nestjs/cli/lib/schematics/schematic.option.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/#nestjs/cli/lib/schematics/schematic.option.js',
'/usr/local/lib/node_modules/#nestjs/cli/lib/schematics/index.js',
'/usr/local/lib/node_modules/#nestjs/cli/actions/generate.action.js',
'/usr/local/lib/node_modules/#nestjs/cli/actions/index.js',
'/usr/local/lib/node_modules/#nestjs/cli/commands/command.loader.js',
'/usr/local/lib/node_modules/#nestjs/cli/commands/index.js',
'/usr/local/lib/node_modules/#nestjs/cli/bin/nest.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Exit status 1
npm ERR!
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! /root/.npm/_logs/2020-05-22T14_14_24_709Z-debug.log
Delete the dist folder and again run yarn start, npm start, yarn start:dev or npm run start:dev to rebuild the dist folder. In addition yarn prebuild or npm run prebuild does the same thing using rimraf
The problem occurs when you change a name and the tsc does not change it in dist and transpiled .js files, so it cannot find the module
I think to the best of my knowledge, nestjs or tsc does that to make the transpilation faster
Nothing else worked for me but the following did:
npm install --save-dev webpack
i'm not completely sure if there is any adverse impact to this though
most important where you started node js the dist/ or / build folder has a worng path which we import or required so for
NPM : npm install --save-dev webpack
and for yarn add webpack this one packeg will slove your problem

How to properly set up dev environment using node and npm for Material.io components?

I've done the codepens provided by Material.io however when I try to follow the same steps using my own files, I always get an error.
> webpack-dev-server --progress
internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module 'webpack/bin/config-yargs'
Require stack:
- C:\Users\willy\Desktop\Wireframes-master\Front Page\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\willy\Desktop\Wireframes-master\Front Page\node_modules\webpack-dev-server\bin\webpack-dev-server.js:54:1)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\willy\\Desktop\\Wireframes-master\\Front Page\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mdc-101-web#0.0.0 start: `webpack-dev-server --progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mdc-101-web#0.0.0 start 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\willy\AppData\Roaming\npm-cache\_logs\2020-04-10T15_13_14_365Z-debug.log
C:\Users\willy\Desktop\Wireframes-master\Front Page>webpack-dev-server --progress
'webpack-dev-server' is not recognized as an internal or external command,
operable program or batch file.
I am still new to web development and most of this log is alien to me, I've found similar issues online however their solutions have not fixed my issue.
Versions:
npm: 6.14.4
webpack: 4.42.1
node.js: 12.16.2
UPDATE: It seems that when I first install npm, everything goes just fine, however there a 3 original vulnerabilities. Before I audit fix them, the npm start command works just fine and successfully compiles. When I run the npm audit to see the details of the vulnerabilities, I use the suggested commands to fix them. Once I've done that it no longer works.

Resources