DeborahK / Angular-GettingStarted

Sample Angular application used in the "Angular: Getting Started" course: http://bit.ly/Angular-GettingStarted
MIT License
2.55k stars 3.98k forks source link

Angular - cli error - apm@0.0.0 start: `ng serve -o` #91

Closed bhargav-18D closed 6 years ago

bhargav-18D commented 6 years ago

Hi,

I am facing issues while starting the server. I tried installing the latest angular cli. As i have nodjs version 8.8.1, it is not compatible with it. So i installed angular cli 1.6.8.

***Logs****

0 info it worked if it ends with ok 1 verbose cli [ 'C:\dir\nodejs\8.8.1\node.exe', 1 verbose cli 'C:\dir\nodejs\8.8.1\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'start' ] 2 info using npm@5.4.2 3 info using node@v8.8.1 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle apm@0.0.0~prestart: apm@0.0.0 6 info lifecycle apm@0.0.0~start: apm@0.0.0 7 verbose lifecycle apm@0.0.0~start: unsafe-perm in lifecycle true 8 9 verbose lifecycle apm@0.0.0~start: CWD: H:\dir\Angular-GettingStarted-master\APM-Start 10 silly lifecycle apm@0.0.0~start: Args: [ '/d /s /c', 'ng serve -o' ] 11 silly lifecycle apm@0.0.0~start: Returned: code: 1 signal: null 12 info lifecycle apm@0.0.0~start: Failed to exec start script 13 verbose stack Error: apm@0.0.0 start: ng serve -o 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (C:\dir\nodejs\8.8.1\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16) 13 verbose stack at emitTwo (events.js:125:13) 13 verbose stack at EventEmitter.emit (events.js:213:7) 13 verbose stack at ChildProcess. (C:\dir\nodejs\8.8.1\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at emitTwo (events.js:125:13) 13 verbose stack at ChildProcess.emit (events.js:213:7) 13 verbose stack at maybeClose (internal/child_process.js:927:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 14 verbose pkgid apm@0.0.0 15 verbose cwd H:\Angular-Training\Angular-GettingStarted-master\APM-Start 16 verbose Windows_NT 6.1.7601 17 verbose argv "C:\dir\nodejs\8.8.1\node.exe" "C:\dir\nodejs\8.8.1\node_modules\npm\bin\npm-cli.js" "start" 18 verbose node v8.8.1 19 verbose npm v5.4.2 20 error code ELIFECYCLE 21 error errno 1 22 error apm@0.0.0 start: ng serve -o 22 error Exit status 1 23 error Failed at the apm@0.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 ]

Can we do away with cli modules and try to run the server?

bhargav-18D commented 6 years ago

An update. I deleted the node_modules, did an 'npm install' again, using cli - 1.6.8. On trying to run the "npm start", i get an error - "missing script: webpack"; "Cannot find module 'webpack/lib/node/NodeTemplatePlugin'" .

DeborahK commented 6 years ago

From the CLI documentation:

Both the CLI and generated project have dependencies that require Node 8.9 or higher, together with NPM 5.5.1 or higher.

You have:

2 info using npm@5.4.2 3 info using node@v8.8.1

Please update your version on node/npm. Then:

1) Delete your node_modules folder 2) Run 'npm install' 3) Run 'npm start'

Let me know if that works for you.

thebadboy007 commented 5 years ago

Hi,

I am facing issues . I am getting error while npm start .

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.4.1 3 info using node@v10.15.3 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle apm@0.0.0~prestart: apm@0.0.0 6 info lifecycle apm@0.0.0~start: apm@0.0.0 7 verbose lifecycle apm@0.0.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle apm@0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Prasun\Practice\APM\node_modules.bin;C:\Program Files\Microsoft MPI\Bin\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\Program Files (x86)\Enterprise Vault\EVClient\;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\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Users\pchatterjee\AppData\Local\Microsoft\WindowsApps; 9 verbose lifecycle apm@0.0.0~start: CWD: C:\Prasun\Practice\APM 10 silly lifecycle apm@0.0.0~start: Args: [ '/d /s /c', 'ng serve -o' ] 11 silly lifecycle apm@0.0.0~start: Returned: code: 1 signal: null 12 info lifecycle apm@0.0.0~start: Failed to exec start script 13 verbose stack Error: apm@0.0.0 start: ng serve -o 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16) 13 verbose stack at EventEmitter.emit (events.js:189:13) 13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:189:13) 13 verbose stack at maybeClose (internal/child_process.js:970:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid apm@0.0.0 15 verbose cwd C:\Prasun\Practice\APM 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.15.3 19 verbose npm v6.4.1 20 error code ELIFECYCLE 21 error errno 1 22 error apm@0.0.0 start: ng serve -o 22 error Exit status 1 23 error Failed at the apm@0.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 ]

thebadboy007 commented 5 years ago

i am using windows 10

DeborahK commented 5 years ago

Other than Failed to exec start script, I'm not really seeing a specific error in this message. A few things to check:

1) Did you perform an npm install? Did that work without error?

2) Did you do anything else after the npm install, like a registry clean or an audit fix?

3) Were there any other messages that appeared before the log dump?

thebadboy007 commented 5 years ago
  1. When i try to install npm install i got some following error. npm WARN @angular/platform-browser-dynamic@7.0.2 requires a peer of @angular/compiler@7.0.2 but none is installed. You must install peer dependencies yourself. npm WARN ajv-keywords@3.4.1 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself. npm WARN bootstrap@4.3.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself. npm WARN bootstrap@4.3.1 requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself. npm WARN codelyzer@4.5.0 requires a peer of @angular/compiler@>=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0 but none is installed. You must install peer dependencies yourself.

  2. Yah i did audit fix after that.

  3. Schema validation failed with the following errors:

    Data path ".builders['app-shell']" should have required property 'class'. Error: Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class'. at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (C:\Prasun\Practice\APM\node_modules\@angular-devkit\core\src\workspace\workspace.js:215:42) at MergeMapSubscriber._tryNext (C:\Prasun\Practice\APM\node_modules\rxjs\internal\operators\mergeMap.js:69:27) at MergeMapSubscriber._next (C:\Prasun\Practice\APM\node_modules\rxjs\internal\operators\mergeMap.js:59:18) at MergeMapSubscriber.Subscriber.next (C:\Prasun\Practice\APM\node_modules\rxjs\internal\Subscriber.js:67:18) at MergeMapSubscriber.notifyNext (C:\Prasun\Practice\APM\node_modules\rxjs\internal\operators\mergeMap.js:92:26) at InnerSubscriber._next (C:\Prasun\Practice\APM\node_modules\rxjs\internal\InnerSubscriber.js:28:21) at InnerSubscriber.Subscriber.next (C:\Prasun\Practice\APM\node_modules\rxjs\internal\Subscriber.js:67:18) at MapSubscriber._next (C:\Prasun\Practice\APM\node_modules\rxjs\internal\operators\map.js:55:26) at MapSubscriber.Subscriber.next (C:\Prasun\Practice\APM\node_modules\rxjs\internal\Subscriber.js:67:18) at SwitchMapSubscriber.notifyNext (C:\Prasun\Practice\APM\node_modules\rxjs\internal\operators\switchMap.js:86:26) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! apm@0.0.0 start: ng serve -o npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the apm@0.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\pchatterjee\AppData\Roaming\npm-cache_logs\2019-08-08T10_10_48_662Z-debug.log

DeborahK commented 5 years ago

Those are not errors, they are warnings. Running audit fix is causing your problem. The code for this project is set up to work with a specific version. Running audit fix tries to update some of the versions and causes problems trying to run the code.

Try this:

1) Delete all of the folders/files.

2) Re-download or unzip the files.

3) Run npm install. Ignore all warnings and do NOT run audit fix.

4) Run npm start.

Let me know if that fixes things for you.

thebadboy007 commented 5 years ago

Thanks Deborah. Now it's working fine

AkshayChowdhary commented 3 years ago

This is the error I get when I run the application using npm start and I have even tried by deleting node modules folder and reinstalling using npm install and npm start thou things didn't work fine..... Hope you help Me out with this ASAP events.js:292 throw er; // Unhandled 'error' event ^

Error: spawn cmd ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn cmd', path: 'cmd', spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:4200/"' ] } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! apm@0.0.0 start: ng serve -o npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the apm@0.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\HP\AppData\Roaming\npm-cache_logs\2020-10-08T10_28_56_090Z-debug.log

DeborahK commented 3 years ago

A few things to check:

NOTE: You added this to a closed issue. To make your issue easier to notice/track, next time please create a new, open issue.

Thanks!