npm run devs fails on a clean install - node.js

I'm following a course and when I run npm run dev on the code I just downloaded (and that works in the video) I get this error. I've reinstalled node and npm, deleted node_modules folder and packale-lock.json and ran npm install again, doesnt work.
Here's the output
$ npm run dev
> twittor-server-client#1.0.0 dev C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting
> ./node_modules/nodemon/bin/nodemon.js server/server
"." no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! twittor-server-client#1.0.0 dev: `./node_modules/nodemon/bin/nodemon.js server/server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the twittor-server-client#1.0.0 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\Administrador\AppData\Roaming\npm-cache\_logs\2020-04-12T18_53_06_036Z-debug.log
Here's the debug log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.2
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle twittor-server-client#1.0.0~predev: twittor-server-client#1.0.0
6 info lifecycle twittor-server-client#1.0.0~dev: twittor-server-client#1.0.0
7 verbose lifecycle twittor-server-client#1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle twittor-server-client#1.0.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Administrador\bin;C:\Program Files\Microsoft MPI\Bin;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Crucial\Crucial Storage Executive;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Java\jdk1.8.0_201\bin;C:\apache-ant-1.10.7\bin;C:\Users\ Usuario\IdeaProjects\mysql-connector-java-5.1.48;C:\ProgramData\chocolatey\bin;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\MinGW\bin;C:\Program Files\nodejs;C:\Users\Administrador\AppData\Roaming\local\bin;C:\Users\Administrador\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrador\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Administrador\AppData\Roaming\npm
9 verbose lifecycle twittor-server-client#1.0.0~dev: CWD: C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting
10 silly lifecycle twittor-server-client#1.0.0~dev: Args: [ '/d /s /c', './node_modules/nodemon/bin/nodemon.js server/server' ]
11 silly lifecycle twittor-server-client#1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle twittor-server-client#1.0.0~dev: Failed to exec dev script
13 verbose stack Error: twittor-server-client#1.0.0 dev: `./node_modules/nodemon/bin/nodemon.js server/server`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:310:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:310:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid twittor-server-client#1.0.0
15 verbose cwd C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v12.16.2
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error twittor-server-client#1.0.0 dev: `./node_modules/nodemon/bin/nodemon.js server/server`
22 error Exit status 1
23 error Failed at the twittor-server-client#1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
And the package.json:
{
"name": "twittor-server-client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server/server.js",
"dev": "./node_modules/nodemon/bin/nodemon.js server/server"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.3"
},
"devDependencies": {
"nodemon": "^1.18.4",
"webpack-dev-server": "^3.10.3"
}
}
Says in the output that the "." in front of the dev script path is not recognized but this is all auto-generated...

I guess, npm cache clean && rm -rf node_modules && npm i should work.
But since you already have nodemon in your dev dependencies. Try
replacing the dev script with "nodemon server/server.js" – Rahul
Sharma Apr 12 at 19:28I guess, npm cache clean && rm -rf node_modules
&& npm i should work. But since you already have nodemon in your dev
dependencies. Try replacing the dev script with "nodemon
server/server.js" – Rahul Sharma Apr 12 at 19:28
This command worked for me:
{
"name": "twittor-server-client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server/server.js",
"dev": "nodemon server/server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.3"
},
"devDependencies": {
"nodemon": "^1.18.4"
}
}
Hope it can help you #Julian

Related

NPM Run <script> doesn't run any script

When I run any script with npm, no matter in what project, I get errors.
For example when I run npm run start I get the following error:
nasteas-MacBook-Pro:newapp nastea$ npm run start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nastea/.npm/_logs/2020-01-02T19_28_32_592Z-debug.log
this is my package.json file:
{
"name": "01-first-app",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"amocrm-api": "^1.3.1"
}
}
These are the logs:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ]
2 info using npm#6.13.4
3 info using node#v12.14.0
4 verbose stack Error: missing script: start
4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:155:19)
4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:63:5
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:116:5
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:436:5
4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:391:45)
4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:434:3)
4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:161:5)
4 verbose stack at ReadFileContext.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:350:20)
4 verbose stack at ReadFileContext.callback (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:115:16)
4 verbose stack at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:239:13)
5 verbose cwd /Users/nastea/Downloads/nodejs-basics-tutorial-master/01-first-app/newapp
6 verbose Darwin 17.7.0
7 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
8 verbose node v12.14.0
9 verbose npm v6.13.4
10 error missing script: start
11 verbose exit [ 1, true ]
I tried the following:
1. uninstalling and re-installing node.
2. npm config get ignore-scripts returns false
What could be the solution? Any help would be much appreciated.
Later edit: node doesn't run any .js file in terminal either.
Edit: run start works now.

Lots of errors when trying to deploy a create-react-app to github pages

Im learning React so i did a project to solidify what i learned and now that i finished i want to host it on a github pages, i knew it would be different from the standard projects i did and how i set up a github pages up until now and because i haven't done this before, i searched around how to do that and found some tutorials and the documentation, i followed them.
But instead of the app being hosted it's just the README file that's being displayed on the actual github pages and the script didn't create a new a gh-pages branch on my repo like it should do
Here's the errors in terminal
> react-recipe-api#0.1.0 predeploy D:\Documents\Git-repo\finished\react-recipe-api
> npm run build
> react-recipe-api#0.1.0 build D:\Documents\Git-repo\finished\react-recipe-api
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
50.79 KB build\static\js\2.56be15e5.chunk.js
1.55 KB build\static\js\main.5045ac4c.chunk.js
785 B build\static\js\runtime-main.781931a1.js
775 B build\static\css\main.f7628ea1.chunk.css
The project was built assuming it is hosted at /react-recipe-finder/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
To publish it at https://nicoding0.github.io/react-recipe-finder , run:
npm run deploy
Find out more about deployment here:
hxxps://bitly/CRA-deploy
> react-recipe-api#0.1.0 deploy D:\Documents\Git-repo\finished\react-recipe-api
> gh-pages -d build
events.js:187
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)←[39m
←[90m at onErrorNT (internal/child_process.js:456:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:80:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)←[39m
←[90m at onErrorNT (internal/child_process.js:456:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:80:21)←[39m {
errno: ←[32m'ENOENT'←[39m,
code: ←[32m'ENOENT'←[39m,
syscall: ←[32m'spawn git'←[39m,
path: ←[32m'git'←[39m,
spawnargs: [ ←[32m'config'←[39m, ←[32m'user.name'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-recipe-api#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-recipe-api#0.1.0 deploy 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\scorpio\AppData\Roaming\npm-cache\_logs\2019-12-13T13_45_56_265Z-debug.log
Here's the log file content:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'deploy'
1 verbose cli ]
2 info using npm#6.12.0
3 info using node#v12.13.0
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle react-recipe-api#0.1.0~predeploy: react-recipe-api#0.1.0
6 verbose lifecycle react-recipe-api#0.1.0~predeploy: unsafe-perm in lifecycle true
7 verbose lifecycle react-recipe-api#0.1.0~predeploy: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Documents\Git-repo\finished\react-recipe-api\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;;C:\Users\scorpio\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\scorpio\AppData\Roaming\npm
8 verbose lifecycle react-recipe-api#0.1.0~predeploy: CWD: D:\Documents\Git-repo\finished\react-recipe-api
9 silly lifecycle react-recipe-api#0.1.0~predeploy: Args: [ '/d /s /c', 'npm run build' ]
10 silly lifecycle react-recipe-api#0.1.0~predeploy: Returned: code: 0 signal: null
11 info lifecycle react-recipe-api#0.1.0~deploy: react-recipe-api#0.1.0
12 verbose lifecycle react-recipe-api#0.1.0~deploy: unsafe-perm in lifecycle true
13 verbose lifecycle react-recipe-api#0.1.0~deploy: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Documents\Git-repo\finished\react-recipe-api\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;;C:\Users\scorpio\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\scorpio\AppData\Roaming\npm
14 verbose lifecycle react-recipe-api#0.1.0~deploy: CWD: D:\Documents\Git-repo\finished\react-recipe-api
15 silly lifecycle react-recipe-api#0.1.0~deploy: Args: [ '/d /s /c', 'gh-pages -d build' ]
16 silly lifecycle react-recipe-api#0.1.0~deploy: Returned: code: 1 signal: null
17 info lifecycle react-recipe-api#0.1.0~deploy: Failed to exec deploy script
18 verbose stack Error: react-recipe-api#0.1.0 deploy: `gh-pages -d build`
18 verbose stack Exit status 1
18 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
18 verbose stack at EventEmitter.emit (events.js:210:5)
18 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
18 verbose stack at ChildProcess.emit (events.js:210:5)
18 verbose stack at maybeClose (internal/child_process.js:1021:16)
18 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
19 verbose pkgid react-recipe-api#0.1.0
20 verbose cwd D:\Documents\Git-repo\finished\react-recipe-api
21 verbose Windows_NT 6.1.7601
22 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
23 verbose node v12.13.0
24 verbose npm v6.12.0
25 error code ELIFECYCLE
26 error errno 1
27 error react-recipe-api#0.1.0 deploy: `gh-pages -d build`
27 error Exit status 1
28 error Failed at the react-recipe-api#0.1.0 deploy script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 1, true ]
And here's my package.json:
{
"name": "react-recipe-api",
"version": "0.1.0",
"private": true,
"homepage": "https://nicoding0.github.io/react-recipe-finder",
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"uuid": "^3.3.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^2.1.1"
}
}
I really don't know what's wrong and i'm kinda lost, i did follow all the steps but i think i got mixed up in the order a bit.
I know Github Pages looks for an index.html in root to display on the page but npm run build creates a new folder with a compiled index.html. If anyone can help, i'd be very grateful, thank you.
Edit: Oh and here's the page: https://nicoding0.github.io/react-recipe-finder/
and my repo: https://github.com/Nicoding0/react-recipe-finder
Edit2: I just tested on a brand new react app created with create-react-app and the same happens, so that tells me it's a problem on my end, what is wrong with my stuff?

Attempting to start a react app, npm start error with "webpack-dev-server --hot"

Please note I have tried what related stack overflow topics have suggested. I've reached the end point of a tutorial for starting a react app and everything installs and runs till the last part.
I'm following the tutorial here:
React Tutorial
I've researched the error codes and redone the whole process 3 times making sure everything matches but it just won't work.
Everything seems to install and work fine until I reach the very bottom of the tutorial when it asks to do type npm start on the command prompt.
This is the error I get each time after I run that:
This is my package.json, exactly following how the tutorial writes it and told me to change "test" "echo \"Error: no test specified\" && exit 1" instead the script object to "start": "webpack-dev-server --hot".
{
"name": "reactapp",
"version": "1.0.0",
"description": "First React App",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --hot"
},
"author": "Kranti Nebhwani",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"webpack": "^4.6.0",
"webpack-dev-server": "^3.1.3"
},
"devDependencies": {
"webpack-cli": "^2.0.15"
}
}
And finally my error log that npm logs out mentioned in the command line:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#5.6.0
3 info using node#v8.11.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle reactapp#1.0.0~prestart: reactapp#1.0.0
6 info lifecycle reactapp#1.0.0~start: reactapp#1.0.0
7 verbose lifecycle reactapp#1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle reactapp#1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Kranti\Desktop\reactApp\node_modules\.bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\Users\Kranti\AppData\Local\Microsoft\WindowsApps;C:\Users\Kranti\AppData\Local\atom\bin;C:\Users\Kranti\AppData\Local\Microsoft\WindowsApps;C:\Python27;C:\Users\Kranti\AppData\Roaming\npm
9 verbose lifecycle reactapp#1.0.0~start: CWD: C:\Users\Kranti\Desktop\reactApp
10 silly lifecycle reactapp#1.0.0~start: Args: [ '/d /s /c', 'webpack-dev-server --hot' ]
11 silly lifecycle reactapp#1.0.0~start: Returned: code: 1 signal: null
12 info lifecycle reactapp#1.0.0~start: Failed to exec start script
13 verbose stack Error: reactapp#1.0.0 start: `webpack-dev-server --hot`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid reactapp#1.0.0
15 verbose cwd C:\Users\Kranti\Desktop\reactApp
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v8.11.1
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error reactapp#1.0.0 start: `webpack-dev-server --hot`
22 error Exit status 1
23 error Failed at the reactapp#1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I've failed at getting react set up multiple times during last year each time following a different tutorial and it's really demotivating as I check and make sure everything is right. Hopefully someone with more experience can see something I don't or know what the error is as I really want to get react running on my system. I'm too poor for a mac system at the moment though I've heard it's easier to set up there and pretty much all tutorials on youtube show it with a mac. Thanks for your time.
The tutorial assumes you are using webpack 1 (tutorial is very old). But you installed webpack 4. Since webpack version 2, property loaders has been renamed to rules and smaller changes have been done. This is why webpack tells you your webpack.config.js is wrong. So you have two options here:
Rename and change your loaders props to match the new rules prop. This might help: https://javascriptplayground.com/moving-to-webpack-2/
Install webpack in version 1: npm install webpack#1.x --save-dev
Or take another tutorial.

Error during 'npm install dev' in Visual Studio Code running on Windows 10

I am learning laravel and when I tried to run npm install dev in integrated terminal of VS Code, it shows error.
Versions I am using.
enter image description here
Console:
enter image description here
Log file report: 0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm#5.5.1
3 info using node#v9.3.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle #~predev: #
6 info lifecycle #~dev: #
7 verbose lifecycle #~dev: unsafe-perm in lifecycle true
8 verbose lifecycle #~dev: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\xampp\htdocs\myapp\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Avishek\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs;C:\Users\Avishek\AppData\Local\Microsoft\WindowsApps;C:\Users\Avishek\AppData\Roaming\Composer\vendor\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\Avishek\AppData\Roaming\npm
9 verbose lifecycle #~dev: CWD: C:\xampp\htdocs\myapp
10 silly lifecycle #~dev: Args: [ '/d /s /c', 'npm run development' ]
11 silly lifecycle #~dev: Returned: code: 2 signal: null
12 info lifecycle #~dev: Failed to exec dev script
13 verbose stack Error: # dev:npm run development
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack at EventEmitter.emit (events.js:159:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:159:13)
13 verbose stack at maybeClose (internal/child_process.js:943:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid #
15 verbose cwd C:\xampp\htdocs\myapp
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v9.3.0
19 verbose npm v5.5.1
20 error code ELIFECYCLE
21 error errno 2
22 error # dev:npm run development
22 error Exit status 2
23 error Failed at the # dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
package.json contents:
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.17",
"bootstrap-sass": "^3.3.7",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.5.7"
}
}
just do npm install if the issue persist try to add --ignore-platform-reqs
The command must be npm install --dev, you just missed the 2 dashes.

webpack-dev-server fails to run

I am new to reactjs and webpack. So I am trying the following awesome video to install webpack and dev server:
Setup Workspace with Webpack
and here is the sample project I am working on:
project
I did everything step by step and now when I run npm start I get the following error:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm- cli.js',
1 verbose cli 'start' ]
2 info using npm#3.10.10
3 info using node#v7.2.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle reactjs-basics#1.0.0~prestart: reactjs-basics#1.0.0
6 silly lifecycle reactjs-basics#1.0.0~prestart: no script for prestart, continuing
7 info lifecycle reactjs-basics#1.0.0~start: reactjs-basics#1.0.0
8 verbose lifecycle reactjs-basics#1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle reactjs-basics#1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\tj\reactjs-basics\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32 ;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Java\jdk1.8.0_111\bin;C:\Users\hminaee\AppData\Roaming\npm
10 verbose lifecycle reactjs-basics#1.0.0~start: CWD: C:\tj\reactjs-basics
11 silly lifecycle reactjs-basics#1.0.0~start: Args: [ '/d /s /c', 'npm run build' ]
12 silly lifecycle reactjs-basics#1.0.0~start: Returned: code: 1 signal: null
13 info lifecycle reactjs-basics#1.0.0~start: Failed to exec start script
14 verbose stack Error: reactjs-basics#1.0.0 start: `npm run build`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid reactjs-basics#1.0.0
16 verbose cwd C:\tj\reactjs-basics
17 error Windows_NT 6.1.7601
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 error node v7.2.1
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error reactjs-basics#1.0.0 start: `npm run build`
22 error Exit status 1
23 error Failed at the reactjs-basics#1.0.0 start script 'npm run build'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the reactjs-basics package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error npm run build
23 error You can get information on how to open an issue for this project with:
23 error npm bugs reactjs-basics
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls reactjs-basics
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
Also here is my package.json file:
{
"name": "reactjs-basics",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "npm run build",
"build": "webpack -d && cp src/index.html dist/index.html && webpack-dev- server --content-base src/ --inline --hot --port 3003",
"build:prod": "webpack -p && cp src/index.html dist/index.html"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.4.1",
"react-dom": "^15.4.1",
"webpack-dev-server": "^1.16.2"
},
"devDependencies": {
"babel-core": "^6.20.0",
"babel-loader": "^6.2.9",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-2": "^6.18.0",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
}
}
I checked the web and I saw many solution regarding to the port. So I change the port to an open port like this : --port 3003 but still webpack-dev-server does not work.
Can anyone help?

Resources