Getting this error messages when using npx create-react-app - node.js

error messages when running npx create-react-app
When trying to create a new react app using create-react-app generator I seem to run into a this downloading error. Not sure how to fix it. I've use npx create-react-app many time before but recently it has stopped working. Any suggestions?
Andrewcarey#Andrews-MacBook-Air Strangers_Things % npx create-react-app my-app
internal/modules/cjs/loader.js:311
throw err;
^
Error: Cannot find module '/Users/andrewcarey/.npm/_npx/c67e74de0542c87c/node_modules/brace-expansion/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:303:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:516:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/andrewcarey/.npm/_npx/c67e74de0542c87c/node_modules/minimatch/minimatch.js:10:14)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32) {
code: 'MODULE_NOT_FOUND',
path: '/Users/andrewcarey/.npm/_npx/c67e74de0542c87c/node_modules/brace-expansion/package.json',
requestPath: 'brace-expansion'
}
npm ERR! code 1
npm ERR! path /Users/andrewcarey/Desktop/Strangers_Things
npm ERR! command failed
npm ERR! command sh -c create-react-app "my-app"
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andrewcarey/.npm/_logs/2021-06-01T00_36_33_693Z-debug.log

what I normally do is let say I want my project to be called "my-app" I create a folder "my-app" open it in my terminal and then type npx create-react-app ./ I'm not sure if this is the best solution but maybe give it a try and see if it works

type in the powershell npm install -g create-react-app then type create-react-app todos-listenter image description here

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/

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

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.

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

create-react-app does not work

i am trying to start with a react project and i installed create-react-app with npm.
When i do the command create-react-app pseudogram i get the following error:
Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module 'C:\Users\leonel\Desktop\pseudogram\node_modules\react-scripts\package.json'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at checkNodeVersion (C:\Users\leonel\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:476:23)
at getPackageName.then.then.then.packageName (C:\Users\leonel\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:283:7)
at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NOT_FOUND' }
I tried with different versions of node and npm and still does not work.
Thanks in advance
$ npm i -g create-react-app . Install it globally.
After that, in your terminal, type $ create-react-app name-of-the-app , then $ cd name-of-the-app and finally $ npm start.
The documentation will print automatically after it finishes installing.

node . and npm start don't work

The title says most of the problem. When I try to run node . I get:
module.js:340
throw err;
^
Error: Cannot find module 'static-favicon'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
There seems to be no modules folder actually. I'm just running express in an empty directory
npm works fine however. This is with a fresh express install if it matters. Any help would be awesome, thanks!
the full error messages:
new-host-2:~ Brennan$ cd Desktop/
new-host-2:Desktop Brennan$ mkdir test4
new-host-2:Desktop Brennan$ cd test4
new-host-2:test4 Brennan$ express -e
create : .
create : ./package.json
create : ./app.js
create : ./public
create : ./public/javascripts
create : ./public/images
create : ./public/stylesheets
create : ./public/stylesheets/style.css
create : ./routes
create : ./routes/index.js
create : ./routes/users.js
create : ./views
create : ./views/index.ejs
create : ./views/error.ejs
create : ./bin
create : ./bin/www
install dependencies:
$ cd . && npm install
run the app:
$ DEBUG=test4 ./bin/www
new-host-2:test4 Brennan$ node app.js
module.js:340
throw err;
^
Error: Cannot find module 'static-favicon'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/Brennan/Desktop/test4/app.js:3:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
new-host-2:test4 Brennan$ npm start app.js
npm ERR! Error: ENOENT, open '/Users/Brennan/Desktop/test4/node_modules/app.js/package.json'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 12.4.0
npm ERR! command "node" "/usr/local/bin/npm" "start" "app.js"
npm ERR! cwd /Users/Brennan/Desktop/test4
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.7
npm ERR! path /Users/Brennan/Desktop/test4/node_modules/app.js/package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Brennan/Desktop/test4/npm-debug.log
npm ERR! not ok code 0
new-host-2:test4 Brennan$ forever app.js
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
module.js:340
throw err;
^
Error: Cannot find module 'static-favicon'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/Brennan/Desktop/test4/app.js:3:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
error: Forever detected script exited with code: 8
After using the express-generator to generate the node application, you need to install the dependencies for the project. This is done via:
$ npm install
Once this is done, you can start the app using npm:
$ npm start
By default, the express generated apps state this as the start command for npm (you can view this in the package.json file):
"start": "node ./bin/www"
So to execute the same thing via the command line, you would run:
$ node ./bin/www
I had the same issue after running the express-generator on a non-empty directory with some node modules already installed in node_modules, especially express itself. Simply nuke the folder, reinstall all your dependencies and you should be good to go:
rm -rf ./node_modules
npm install
npm start
EDIT: Tuns out that at some stage in the process I had installed serve-favicon and saved that to the local package.json. Looks like the express generator failed to add that dependency. Therefore:
npm install serve-favicon --save
npm start
given a dir tree like:
myapp
- lib
- favicon.ico
- app.js
- package.json
- node_modules (npm installs all modules in here)
if you are trying to access favicon.ico in your app.js
var express = require('express'),
fs = require('fs'); // this is for reading static files
var favicon = require(fs.readFileSync('./lib/favicon.ico'));
the var for favicon may not be what you expect. The best way for serving static files would be to set up a static directory with a route so anyone hitting that route with a param gets that files: for example:
https://mynodeapp.com/static/images/{param}
where param would be the name of the file (this is an example using Hapi - express has something similiar for serving static files)
Use serve-favicon instead of static-favicon.
Also verify that you have serve-favicon installed correctly.
Do cd serve-favicon, check package.json, and then run npm install to have all dependencies installed correctly.
Do npmstart which installs all the required modules for your project

Resources