Aristophanes
Aristophanes

Reputation: 485

What should I set my "start" script to in NPM package.json?

I'm unable to run npm start because I don't have a "start" script in my package.json. The problem is, I don't know what to enter there. How do I find out what I should set my start script to? I've tried various values like "start": "node app.js" and "start": "node server.js" but they haven't worked.

This is the debug log when I try npm start

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 [email protected]
3 info using [email protected]
4 verbose config Skipping project config: C:\Users\Aristophanes/.npmrc. (matches userconfig)
5 verbose stack Error: missing script: start
5 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
5 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
5 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
5 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:418:5
5 verbose stack     at handleExists (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:382:20)
5 verbose stack     at fs.stat (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:390:33)
5 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
5 verbose stack     at FSReqCallback.oncomplete (fs.js:161:21)
6 verbose cwd C:\Users\Aristophanes
7 verbose Windows_NT 10.0.17134
8 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
9 verbose node v11.1.0
10 verbose npm  v6.4.1
11 error missing script: start
12 verbose exit [ 1, true ]

Update: I now have "start": "node.js" in my scripts section of package.json. When I try npm start now I get this in error log:

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 [email protected]
3 info using [email protected]
4 verbose config Skipping project config: C:\Users\Aristophanes/.npmrc. (matches userconfig)
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info lifecycle [email protected]~prestart: [email protected]
7 verbose lifecycle [email protected]~prestart: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~prestart: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Aristophanes\node_modules\.bin;C:\Program Files\cmder\bin;C:\Program Files\cmder\vendor\conemu-maximus5\ConEmu\Scripts;C:\Program Files\cmder\vendor\conemu-maximus5;C:\Program Files\cmder\vendor\conemu-maximus5\ConEmu;C:\Program Files\nodejs;C:\Users\Aristophanes\AppData\Roaming\npm;C:\ProgramData\Boxstarter;C:\Python27\;C:\Python27\Scripts;C:\Program Files\Microsoft MPI\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:\Go\bin;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:\Users\Aristophanes\Go\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\Aristophanes\AppData\Local\Programs\Python\Python37;C:\Users\Aristophanes\AppData\Local\Programs\Python\Python37\Scripts;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\PHP;C:\ProgramData\chocolatey\bin;C:\Program Files\Geth;C:\HashiCorp\Vagrant\bin;C:\Program Files\Git\cmd;C:\composer;C:\Program Files\nodejs\;C:\Program Files\Git\mingw64;C:\Program Files\Git\usr\bin;C:\Program Files\cmder
9 verbose lifecycle [email protected]~prestart: CWD: C:\Users\Aristophanes
10 silly lifecycle [email protected]~prestart: Args: [ '-c', 'npm install' ]
11 silly lifecycle [email protected]~prestart: Returned: code: 1  signal: null
12 info lifecycle [email protected]~prestart: Failed to exec prestart script
13 verbose stack Error: [email protected] prestart: `npm install`
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:182: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:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:257:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\Aristophanes
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 v11.1.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] prestart: `npm install`
22 error Exit status 1
23 error Failed at the [email protected] prestart script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Upvotes: 1

Views: 2580

Answers (1)

Jawad Akram
Jawad Akram

Reputation: 29

please try to write start inside scripts by giving a path to your server file.

"start": "node ./index.js",

Upvotes: 3

Related Questions