prerender charts with dc with node.js - node.js

I am trying to prerender charts with dc.js using npm
but when i include dc in my code it throws error, I am a nwebie in node.js, Tried searching for answers no luck, may be it should be a version error i learnt that jsdom version > 1 has no createWindow(); methord but changing version and calling npm install and update dint work either.. Any Help is much appriciated, thanks in advance
my package.json
{
"name": "binode",
"version": "1.0.0",
"description": "binode testing",
"main": "index.js",
"scripts": {
"start": "node index"
},
"author": "abc",
"license": "MIT",
"dependencies": {
"body-parser": "^1.13.3",
"d3": "^3.5.6",
"dc": "^1.7.3",
"express": "^4.13.3",
"jsdom": "^1.5.0"
}
}
Error :
/learn/nodeSample/biNode/node_modules/dc/globals.js:2
window = global.window = document.createWindow();
^
TypeError: undefined is not a function
at Object.<anonymous> (/Volumes/Official/learn/nodeSample/biNode/node_modules/dc/globals.js:2:39)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Volumes/Official/learn/nodeSample/biNode/node_modules/dc/index.js:8:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.12.7
npm ERR! npm v2.14.1
npm ERR! code ELIFECYCLE
npm ERR! binode#1.0.0 start: `node index`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the binode#1.0.0 start script 'node index'.
npm ERR! This is most likely a problem with the binode package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index
npm ERR! You can get their info via:
npm ERR! npm owner ls binode
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Volumes/Official/learn/nodeSample/biNode/npm-debug.log
npm-debug.log :
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ]
2 info using npm#2.14.1
3 info using node#v0.12.7
4 verbose node symlink /usr/local/bin/node
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart binode#1.0.0
7 info start binode#1.0.0
8 verbose unsafe-perm in lifecycle true
9 info binode#1.0.0 Failed to exec start script
10 verbose stack Error: binode#1.0.0 start: `node index`
10 verbose stack Exit status 1
10 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
10 verbose stack at EventEmitter.emit (events.js:110:17)
10 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
10 verbose stack at ChildProcess.emit (events.js:110:17)
10 verbose stack at maybeClose (child_process.js:1015:16)
10 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
11 verbose pkgid binode#1.0.0
12 verbose cwd /Volumes/Official/learn/nodeSample/biNode
13 error Darwin 14.5.0
14 error argv "node" "/usr/local/bin/npm" "start"
15 error node v0.12.7
16 error npm v2.14.1
17 error code ELIFECYCLE
18 error binode#1.0.0 start: `node index`
18 error Exit status 1
19 error Failed at the binode#1.0.0 start script 'node index'.
19 error This is most likely a problem with the binode package,
19 error not with npm itself.
19 error Tell the author that this fails on your system:
19 error node index
19 error You can get their info via:
19 error npm owner ls binode
19 error There is likely additional logging output above.
20 verbose exit [ 1, true ]
my simple js file:
var express = require('express');
var app = express();
var d3 = require('d3');
var dc = require('dc');
var crossfilter = require('crossfiler');
var jsdom = require('jsdom');
global.d3 = d3;
var port = 2000;
app.listen(port,function(){
console.log("app listing port "+port)
});
i was just getting started at the beginning itself it threw error

I tried running npm install inside node_modules/dc
Then there was one more issue index.js no dc is defined added
changed require('./dc') to dc =require('./dc')
Now its working..

Related

Symfony 5.2 + Webpack Encore: npm run shows error 'Unexpected token'

I have setup a new Symfony 5.2 project and added Webpack Encore on a shared Server with no root access.
Yarn is not available on this machine, so I used npm:
// setup new Symfony 5.2 project
symfony new sym5 --version=5.2 --full
...
cd sym5
// add Webpack Encore
composer require symfony/webpack-encore-bundle
npm install
...
// try to compile assets
npm run dev
I have made no changes to the webpack.config.js and asset/ files which have been automatically created. Running npm run dev leads to an Unexpected token error:
npm run dev
> # dev /customers/123/webpages/sym5
> encore dev
/customers/123/webpages/sym5/node_modules/pkg-up/index.js:4
module.exports = async ({cwd} = {}) => findUp('package.json', {cwd});
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
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> (/customers/123/webpages/sym5/node_modules/#symfony/webpack-encore/lib/config/parse-runtime.js:13:15)
npm ERR! Linux 3.18.117-pvops-xen-x64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.11.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! # dev: `encore dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script 'encore dev'.
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 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! encore dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /customers/123/webpages/sym5/npm-debug.log
Since the error is not reported in any my custom files, I assume that this is a problem of Node.js / Webpack itself? Is this correct?
The message says, that one should use the latest versions of node.js and npm. The versions available on the server (node v6.11.3 and npm v3.10.10) are indeed quite old but without root access I cannot change this, can I?
However, since the adding / installing Webpack Encore using these node.js and npm version worked without any problem, I wonder if using these old version is really the cause of the problem.
Is there anything I can do to find the actual cause and to solve the problem?
// /customers/123/webpages/sym5/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm#3.10.10
3 info using node#v6.11.3
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle #~predev: #
6 silly lifecycle #~predev: no script for predev, continuing
7 info lifecycle #~dev: #
8 verbose lifecycle #~dev: unsafe-perm in lifecycle true
9 verbose lifecycle #~dev: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/customers/123/webpages/sym5/node_modules/.bin:/customers/123/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/customers/123/.gem/bin
10 verbose lifecycle #~dev: CWD: /customers/123/webpages/sym5
11 silly lifecycle #~dev: Args: [ '-c', 'encore dev' ]
12 silly lifecycle #~dev: Returned: code: 1 signal: null
13 info lifecycle #~dev: Failed to exec dev script
14 verbose stack Error: # dev: `encore dev`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/lib/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> (/usr/lib/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:920:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
15 verbose pkgid #
16 verbose cwd /customers/123/webpages/sym5
17 error Linux 3.18.117-pvops-xen-x64
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
19 error node v6.11.3
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error # dev: `encore dev`
22 error Exit status 1
23 error Failed at the # dev script 'encore dev'.
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 package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error encore dev
23 error You can get information on how to open an issue for this project with:
23 error npm bugs
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

run start:dev failes Unexpected identifier in concurrently

I'm rather new to the nodejs world and having trouble with some basics ,
when I do npm install it shows a few warn messages but complete it .
when I do npm build it works fine
but when I do run start:dev it crashes with this error message :
concurrently\bin\concurrently.js:140
let lastColor;
^^^^^^^^^
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start:dev"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! izi-backend#0.0.1 start:dev: `concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json" `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the izi-backend#0.0.1 start:dev script 'concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json" '.
npm ERR! This is most likely a problem with the izi-backend package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json"
npm ERR! You can get their info via:
npm ERR! npm owner ls izi-backend
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\dev\iziMobile\izi-server\npm-debug.log
where npm run start:dev is defined as :
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" "
also printing out npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files (x86)\nodejs\\node.exe',
1 verbose cli 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'start:dev' ]
2 info using npm#2.7.4
3 info using node#v0.12.2
4 verbose node symlink C:\Program Files (x86)\nodejs\node.exe
5 verbose run-script [ 'prestart:dev', 'start:dev', 'poststart:dev' ]
6 info prestart:dev izi-backend#0.0.1
7 info start:dev izi-backend#0.0.1
8 verbose unsafe-perm in lifecycle true
9 info izi-backend#0.0.1 Failed to exec start:dev script
10 verbose stack Error: izi-backend#0.0.1 start:dev: concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json"
10 verbose stack Exit status 1
10 verbose stack at EventEmitter. (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\lifecycle.js:213:16)
10 verbose stack at EventEmitter.emit (events.js:110:17)
10 verbose stack at ChildProcess. (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\spawn.js:14:12)
10 verbose stack at ChildProcess.emit (events.js:110:17)
10 verbose stack at maybeClose (child_process.js:1015:16)
10 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
11 verbose pkgid izi-backend#0.0.1
12 verbose cwd C:\dev\iziMobile\izi-server
13 error Windows_NT 6.3.9600
14 error argv "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "run" "start:dev"
15 error node v0.12.2
16 error npm v2.7.4
17 error code ELIFECYCLE
18 error izi-backend#0.0.1 start:dev: concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json"
18 error Exit status 1
19 error Failed at the izi-backend#0.0.1 start:dev script 'concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json" '.
19 error This is most likely a problem with the izi-backend package,
19 error not with npm itself.
19 error Tell the author that this fails on your system:
19 error concurrently --handle-input "wait-on dist/main.js && nodemon" "tsc -w -p tsconfig.build.json"
19 error You can get their info via:
19 error npm owner ls izi-backend
19 error There is likely additional logging output above.
20 verbose exit [ 1, true ]<
Concurrently is a package I take in packages.json so I doubt there is really an error there...
Am I missing anything ?
Any help will do at this point
Node v0.12.2 does not support the let declarations.
See here for the full version support matrix.
You are using node version v0.12.2. let syntax is not supported.
From node.green you can see that let is supported from Node v6.4.x

React.js code is not running after installing it using nodejs through npm installer

I was trying to learn react, so I have this sample code of my first react app, and I am trying to get it work but after running npm install followed by npm start I receive the following error:
C:\Users\Ak\Desktop\reactapp>npm start
> reactapp#1.0.0 start C:\Users\Ak\Desktop\reactapp
> webpack-dev-server --hot
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 i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
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:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\Ak\Desktop\reactapp\node_modules\webpack-dev-server\bin\webpack-dev-server.js:60:1)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787: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! reactapp#1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp#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! C:\Users\Ak\AppData\Roaming\npm-cache\_logs\2019-06-07T07_08_01_594Z-debug.log
Don't know how to solve this issue.
Here is my log file.
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#6.9.0
3 info using node#v10.16.0
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\Ak\Desktop\reactapp\node_modules\.bin;G:\Software files\Python\Scripts\;G:\Software files\Python\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;G:\Software files\Brackets Editor\command;C:\Program Files\nodejs\;C:\Users\Ak\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\Ak\AppData\Local\Programs\Python\Python36\;G:\Software files\Java\bin;C:\Users\Ak\AppData\Local\Microsoft\WindowsApps;G:\Software files\NMDVPN\bin;C:\Users\Ak\AppData\Roaming\npm
9 verbose lifecycle reactapp#1.0.0~start: CWD: C:\Users\Ak\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:301:16)
13 verbose stack at EventEmitter.emit (events.js:198: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:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid reactapp#1.0.0
15 verbose cwd C:\Users\Ak\Desktop\reactapp
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.16.0
19 verbose npm v6.9.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 ]
Here is my package.json file:
{
"name": "reactapp",
"version": "1.0.0",
"description": "Learning ReactJs with AK",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --hot"
},
"keywords": [
"npm",
"learn",
"react"
],
"author": "AK",
"license": "UNLICENSED",
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.6",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"webpack": "^4.33.0",
"webpack-dev-server": "^3.7.0"
}
}
I have installed the react using Nodejs through npm installer.
The first 3 lines of the error message advise what to do.
You need to install webpack-cli in order to run the webpack-dev-server. If you run the command it's giving you, you'll install webpack-cli as a devDependency and it'll all run.
If you're going to be using webpack a lot going forward it may be worth installing it globally, rather than needing to add it each time.
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 i -D webpack-cli

create-react-app npm start Error: Cannot find module '#webassemblyjs/ast'

I am just starting to learn react and I'm following the first part of this tutorial. https://www.codecademy.com/articles/how-to-create-a-react-app
I have run the following commands in Terminal:
npm install -g create-react-app
create-react-app ravenous
# I've also tried npx create-react-app ravenous as per the official React website)
# Both timesI receive a successful output that ends with 'Happy hacking'
cd ravenous
npm start
But I receive the following error in the terminal.
npm start
> ravenous#0.1.0 start /Users/sarah/sites/ravenous
> react-scripts start
module.js:559
throw err;
^
Error: Cannot find module '#webassemblyjs/ast'
at Function.Module._resolveFilename (module.js:557:15)
at Function.Module._load (module.js:484:25)
at Module.require (module.js:606:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/sarah/sites/ravenous/node_modules/webpack/lib/wasm/WebAssemblyParser.js:7:11)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ravenous#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ravenous#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/sarah/.npm/_logs/2018-10-16T17_12_05_840Z-debug.log
In node_modules I do have the #webassemblyjs/ast folder.
The debug.log has this:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm#5.6.0
3 info using node#v9.6.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle ravenous#0.1.0~prestart: ravenous#0.1.0
6 info lifecycle ravenous#0.1.0~start: ravenous#0.1.0
7 verbose lifecycle ravenous#0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle ravenous#0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/s$
9 verbose lifecycle ravenous#0.1.0~start: CWD: /Users/sarah/sites/ravenous
10 silly lifecycle ravenous#0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle ravenous#0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle ravenous#0.1.0~start: Failed to exec start script
13 verbose stack Error: ravenous#0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at EventEmitter.emit (events.js:127:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:127:13)
13 verbose stack at maybeClose (internal/child_process.js:933:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid ravenous#0.1.0
15 verbose cwd /Users/sarah/sites/ravenous
16 verbose Darwin 16.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v9.6.1
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error ravenous#0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the ravenous#0.1.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 ]
Here is my ravenous/package.json
{
"name": "ravenous",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-scripts": "2.0.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
I've checked the folder permissions on the filesystem once the ravenous folder is created, set everything to Read & Write and then retried npm start but this doesn't seem to make a difference.
I've tried deleting package-lock.json and node_modules and rerunning npm install. It doesn't help the issue although strangely package-lock.json is not recreated when I do this.
I am on Mac OS Sierra 10.12.6
npm -v gives me 5.6.0
node -v gives me 9.6.1
I downloaded the "recommended for most users" release of Node.js (currently 8.12.0 LTS) and reinstalled node.
I'm now on node 8.12.0 and npm 6.4.1 and npm start is now working.

Can't launch nodejs + express basic program

I am having a bit of trouble with a basic nodejs and express program.
The problem is when I use npm start which should run node .\bin\www I get these errors:
C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api>npm start
cdc-api#0.0.0 start C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api
node .\bin\www
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at Function.app.listen (C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api\node_mo
dules\express\lib\application.js:556:24)
at Object.<anonymous> (C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api\bin\www:
7:18)
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)
npm ERR! cdc-api#0.0.0 start: `node .\bin\www`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the cdc-api#0.0.0 start script.
npm ERR! This is most likely a problem with the cdc-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node .\bin\www
npm ERR! You can get their info via:
npm ERR! npm owner ls cdc-api
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api\npm-debug.log
npm ERR! not ok code 0
C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api>
and here is what I have in npm-debug.log:
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#1.4.28
3 info using node#v0.10.32
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart cdc-api#0.0.0
7 info start cdc-api#0.0.0
8 verbose unsafe-perm in lifecycle true
9 info cdc-api#0.0.0 Failed to exec start script
10 error cdc-api#0.0.0 start: `node .\bin\www`
10 error Exit status 8
11 error Failed at the cdc-api#0.0.0 start script.
11 error This is most likely a problem with the cdc-api package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error node .\bin\www
11 error You can get their info via:
11 error npm owner ls cdc-api
11 error There is likely additional logging output above.
12 error System Windows_NT 6.2.9200
13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd C:\Users\Moucheg\Desktop\projets\cdc\cdc-api
15 error node -v v0.10.32
16 error npm -v 1.4.28
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]
I have tried everything I found on internet (reinstall node, recreate package.json, ...) I can't get it to work.
FYI, I am on Windows 8 (if it's of any help)
Thank you in advance for your help guys (and girls ;)).
The error "EADDRINUSE" means the port you're attempting to use is already in use by your system. Try changing the port used in your app or closing whatever program is using it.
The error means that the port is currently in use.
Update the code to use a different port. Often times, node.js/express samples assign the port in app.js.
EADDRINUSE happens when your code is using the same port of another program.
You can try to use another port to see if the problem is resolved.

Resources