React npm start throwing errors - node.js

I am creating a simple HelloWorld application using Node and react. I followed this tutorial when I run
npm start
I get the following error:
> test1#1.0.0 start C:\Users\Saeed\Work\Test1
> webpack-dev-server
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
module.js:549
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Saeed\Work\Test1\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test1#1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test1#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
this is my package.json:
{
"name": "test1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"webpack": "^4.16.3",
"webpack-dev-server": "^3.1.5"
}
}
can anyone one point me out to my error? I npm install webpack-cli -D would solve the problem.

Related

issues with running npm start on wsl2

I'm transitioning from working on an ubuntu remote server that I accessed through ssh, to my local windows machine and wsl2
I don't know JS at all, but what worked on the server suddenly is not working on my computer at all. I've tried all different kinds of npm commands found here, but to no avail
This is the full error I'm getting
nick#GameCube:~/Winions.gg/frontend/my-app$ npm start
> my-app#0.1.0 start /home/nick/Winions.gg/frontend/my-app
> react-scripts start
/home/nick/Winions.gg/frontend/my-app/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/nick/Winions.gg/frontend/my-app/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! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.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! /home/nick/.npm/_logs/2022-12-11T03_44_57_094Z-debug.log
This is my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"homepage": "https://winions.gg",
"dependencies": {
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^1.2.0",
"react": "^18.2.0",
"react-bootstrap": "^2.6.0",
"react-circular-progressbar": "^2.1.0",
"react-dom": "^18.2.0",
"react-icons": "^4.6.0",
"react-router-dom": "^6.4.3",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"babel-eslint": "^10.1.0"
}
}
I just want to be able to run the react app. God help me please
Copying from my comment so this shows up as answered in the feed:
Older versions of Node don't support public fields on classes. 12.4 is the first Node version to support that syntax, and Jest is transpiled from TypeScript to support Node 14 as of this date. This table is a good resource for finding out what newer features of EcmaScript are supported in which versions of Node.

App not deploying with "start node.js" script

I'm trying to deploy a Discord bot with Google Cloud. Whenever I try to deploy using gcloud app deploy, I get this error:
> discord-bot#1.0.0 start /app
> node index.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'discord.js-commando'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/index.js:1:28)
at Module._compile (internal/modules/cjs/loader.js:778:30)
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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-bot#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-bot#1.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! /root/.npm/_logs/2019-12-09T05_48_58_649Z-debug.log
This is what my package.json looks like:
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
"dev": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^11.4.2",
"dotenv": "^7.0.0"
},
"devDependencies": {
"nodemon": "^1.18.11"
}
}
Any help would be greatly appreciated. Thank you!
try install the required package discord.js-commando. It's not in package.json. You can install it with npm install discord.js-commando --save

Error: Cannot find module './util/resolveCommand'

I'm not able to npm start anymore due to a problem with the util npm I think.
I tried to update all the packages and to remove util and re-install it. How could I solve this?
Error: Cannot find module './util/resolveCommand'
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 Object.<anonymous> (/Users/cyruslognonne/Dropbox/C-T-L-K_Master/A_Mandats/A_En cours/LEV/B_Jam/lev_dev/node_modules/cross-spawn/lib/parse.js:3:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lev_dev#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lev_dev#0.1.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/cyruslognonne/.npm/_logs/2017-12-03T19_21_25_874Z-debug.log
Here's my package.json.
{
"name": "lev_dev",
"version": "0.1.0",
"private": true,
"dependencies": {
"package.json": "^2.0.1",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-marquee": "^0.1.1",
"react-scripts": "1.0.17",
"react-slick": "^0.15.4",
"slick-carousel": "^1.8.1",
"util": "^0.10.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Thanks, Cyrus
As the error states, the problem is with the cross-spawn module, which is used by react-scripts. The issue is not because of util module.
Try the following to update the dependencies properly and see if it works.
npm install -g npm#latest # to update npm.
rm -rf node_modules # to remove the existing modules.
npm install # to re-install the project dependencies.
You firstly need to
npm clean cache force
and then go to your git bash if you are using windows and run
rm -rf node_modules
and after removing the node_modules then run
npm install

TypeError: Cannot read property 'length' of undefined in tsc.js

I have created a nodejs api project using typescript. But I am not able to start it. This is the command I am running
npm start
This is the output of this command
> project1#1.0.0 prestart D:\Workspace
> tsc
D:\Workspace\node_modules\typescript\lib\tsc.js:9921
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
^
TypeError: Cannot read property 'length' of undefined
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9921:70)
at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
at D:\Workspace\node_modules\typescript\lib\tsc.js:17392:64
at visitNode (D:\Workspace\node_modules\typescript\lib\tsc.js:9533:24)
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9918:25)
at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
at D:\Workspace\node_modules\typescript\lib\tsc.js:17392:64
at visitNodes (D:\Workspace\node_modules\typescript\lib\tsc.js:9542:30)
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9891:24)
at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
at bindChildrenWorker (D:\Workspace\node_modules\typescript\lib\tsc.js:15178:25)
at bindChildren (D:\Workspace\node_modules\typescript\lib\tsc.js:15129:17)
at bindContainer (D:\Workspace\node_modules\typescript\lib\tsc.js:15122:17)
at bind (D:\Workspace\node_modules\typescript\lib\tsc.js:16214:21)
at Object.forEach (D:\Workspace\node_modules\typescript\lib\tsc.js:275:30)
at bindEach (D:\Workspace\node_modules\typescript\lib\tsc.js:15149:20)
at visitNodes (D:\Workspace\node_modules\typescript\lib\tsc.js:9538:24)
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9707:24)
at bindEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:15165:16)
at bindChildrenWorker (D:\Workspace\node_modules\typescript\lib\tsc.js:15254:21)
at bindChildren (D:\Workspace\node_modules\typescript\lib\tsc.js:15129:17)
at bindContainer (D:\Workspace\node_modules\typescript\lib\tsc.js:15093:17)
at bind (D:\Workspace\node_modules\typescript\lib\tsc.js:16214:21)
at bindSourceFile (D:\Workspace\node_modules\typescript\lib\tsc.js:14851:17)
at Object.bindSourceFile (D:\Workspace\node_modules\typescript\lib\tsc.js:14809:9)
at initializeTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:36496:20)
at Object.createTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:18543:9)
at getDiagnosticsProducingTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:56042:93)
at Object.getGlobalDiagnostics (D:\Workspace\node_modules\typescript\lib\tsc.js:56370:53)
at compileProgram (D:\Workspace\node_modules\typescript\lib\tsc.js:59092:78)
at compile (D:\Workspace\node_modules\typescript\lib\tsc.js:59051:26)
at performCompilation (D:\Workspace\node_modules\typescript\lib\tsc.js:58940:33)
at Object.executeCommandLine (D:\Workspace\node_modules\typescript\lib\tsc.js:58883:9)
at Object.<anonymous> (D:\Workspace\node_modules\typescript\lib\tsc.js:59241:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Workspace\node_modules\typescript\bin\tsc:2:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! project1#1.0.0 prestart: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project1#1.0.0 prestart script 'tsc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the project1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs project1
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls project1
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\Workspace\npm-debug.log
and my package.json
{
"name": "project1",
"version": "1.0.0",
"description": "Project 1",
"main": "index.js",
"scripts": {
"prestart": "tsc",
"start": "concurrently \"tsc --watch \" \"nodemon server.js startServer\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"dependencies": {
"#types/es6-promise": "0.0.32",
"body-parser": "^1.16.0",
"es6-map": "^0.1.5",
"giuseppe": "^1.2.0",
"make-runnable": "^1.0.7",
"request": "^2.79.0",
"request-promise": "^4.1.1",
"typescript": "^2.1.4"
},
"devDependencies": {
"#types/chai": "^3.4.34",
"concurrently": "^3.1.0",
"nodemon": "^1.11.0"
}
}
I have tried deleting node_modules folder and clearing cache using
npm cache clear
and then installing it again using
npm install
but fail to start? what could be the issue?
The issue was with typescript itself. Here is the issue raised on Github
https://github.com/Microsoft/TypeScript/issues/18301
but now the issue has been fixed.
Just update typescript module
npm update typescript --save

`npm run gulp` can not find module 'gulp-shell'?

I've deleted node modules folder and installed npm using npm install command. My gulpfile.js is also perfect because other people are working perfectly with this config, even I did with this config from my another machine. But when I try to run npm run gulp from current machine it shows below errors.
Fahads-MacBook-Pro:dark-web jim$ npm run gulp
> jetaport#1.0.0 gulp /Users/jim/Documents/JETAPORT/dark-web
> gulp
module.js:327
throw err;
^
Error: Cannot find module 'gulp-shell'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/jim/Documents/JETAPORT/dark-web/gulpfile.js:6:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "gulp"
npm ERR! node v4.4.2
npm ERR! npm v2.15.0
npm ERR! code ELIFECYCLE
npm ERR! jetaport#1.0.0 gulp: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jetaport#1.0.0 gulp script 'gulp'.
npm ERR! This is most likely a problem with the jetaport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs jetaport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls jetaport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jim/Documents/JETAPORT/dark-web/npm-debug.log
And here is the package.json file
{
"name": "jetaport",
"version": "1.0.0",
"description": "The Jetaport Gulp dependencies.",
"main": "index.js",
"author": "Alexander Khost",
"repository": {
"type": "git",
"url": "git://github.com/akhost/Jetaport.git"
},
"license": "ISC",
"dependencies": {
"autoprefixer": "^6.3.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"bower": "^1.7.2",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-cssnano": "^2.0.0",
"gulp-imagemin": "^2.4.0",
"gulp-postcss": "^6.0.1",
"imagemin-pngquant": "^4.2.0",
"laravel-elixir": "^5.0.0",
"pixrem": "^3.0.0",
"postcss-conditionals": "^2.0.0",
"postcss-each": "^0.9.1",
"postcss-import": "^7.1.3",
"postcss-math": "0.0.1",
"postcss-mixins": "^4.0.1",
"postcss-nested": "^1.0.0",
"postcss-reporter": "^1.3.0",
"postcss-scss": "^0.1.3",
"postcss-simple-extend": "^1.0.0",
"postcss-simple-vars": "^1.1.0",
"precss": "^1.3.0",
"yargs": "^4.4.0"
},
"bugs": {
"url": "https://github.com/akhost/Jetaport/issues"
},
"homepage": "https://github.com/akhost/Jetaport#readme",
"directories": {
"test": "tests"
},
"devDependencnpm ies": {
"gulp-notify": "^2.2.0"
},
"scripts": {
"gulp": "gulp",
"bower": "bower"
},
"devDependencies": {
"gulp": "^3.9.1"
}
}
Your package.json is missing the gulp-shell package. You have to install it with npm install --save gulp-shell (or --save-dev if you want to put it under devDependencies). Not sure how others got it working, but I'm pretty confident they have installed it themselves, similarly to what I've suggested, without the save flag, which is the reason it's missing in package.json.

Resources