angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.74k stars 11.98k forks source link

Unable to serve or build via npm run #12947

Closed cray2015 closed 5 years ago

cray2015 commented 5 years ago

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

node --version = v8.11.1 npm --version = 5.6.0 ng --version = Angular CLI: 6.0.8 Node: 8.11.1 OS: win32 x64 Angular: 6.1.10 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.8 @angular-devkit/build-angular 0.6.8 @angular-devkit/build-optimizer 0.6.8 @angular-devkit/core 0.6.8 @angular-devkit/schematics 0.6.8 @angular/cdk 6.4.7 @angular/cli 6.0.8 @angular/tsc-wrapped 0.5.2 @ngtools/json-schema 1.1.0 @ngtools/webpack 6.0.8 @schematics/angular 0.6.8 @schematics/update 0.6.8 rxjs 6.3.3 typescript 2.7.2 webpack 4.8.3

OS: Windows 10 pro

Repro steps

I created a npm script in order to serve the UAT environment in our project. It was working as expected for a couple of days then suddenly it stopped working. Now when I run the command npm run serve-local it throws an error.

vizdom-web@0.0.0 serve-local D:\Neurosensum\Vizdom\vizdom\vizdom-web ng serve --configuration=uat-local

As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release, which will only support Node 6.9 and greater. This package will be officially deprecated shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".

The option '--configuration' is not registered with the serve command. Run ng serve --help for a list of supported options. Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (D:\Neurosensum\Vizdom\vizdom\vizdom-web\node_modules\angular-cli\tasks\serve.js:22:61) at D:\Neurosensum\Vizdom\vizdom\vizdom-web\node_modules\angular-cli\commands\serve.run.js:22:22 at at process._tickCallback (internal/process/next_tick.js:188:7) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vizdom-web@0.0.0 serve-local: ng serve --configuration=uat-local npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vizdom-web@0.0.0 serve-local 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\Vibhanshu Biswas\AppData\Roaming\npm-cache_logs\2018-11-13T08_08_08_191Z-debug.log

this happens for both serve and build commands. Where as when I directly run ng serve --configuration=uat-local it runs successfully.

Our package JSON looks like this. { "name": "vizdom-web", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "build-prod": "ng build --prod", "build-uat": "ng build --configuration=uat", "serve-local": "ng serve --configuration=uat-local" }, "private": true, "dependencies": { "@angular/animations": "^6.0.3", "@angular/cdk": "^6.4.0", "@angular/common": "^6.0.3", "@angular/compiler": "^6.0.3", "@angular/core": "^6.0.3", "@angular/forms": "^6.0.3", "@angular/http": "^6.0.3", "@angular/platform-browser": "^6.0.3", "@angular/platform-browser-dynamic": "^6.0.3", "@angular/router": "^6.0.3", "@handsontable/angular": "^2.0.0", "@ngui/map": "^0.30.3", "@types/crypto-js": "^3.1.43", "@types/googlemaps": "^3.30.13", "angular2-uuid": "^1.1.1", "angular2gridster": "^6.0.2", "angular5-csv": "^0.2.10", "classlist.js": "^1.1.20150312", "core-js": "^2.5.4", "crypto-js": "^3.1.9-1", "echarts": "^4.2.0-rc.2", "file-saver": "^2.0.0-rc.3", "filepond-plugin-file-validate-type": "^1.1.0", "filepond-plugin-image-preview": "^1.2.0", "google-libphonenumber": "^3.0.9", "handsontable": "^6.1.1", "inline-edit-js": "^1.1.1", "moment": "^2.22.2", "monaco-editor": "^0.14.3", "ng-click-outside": "^4.0.0", "ng-zorro-antd": "1.7.0", "ng2-dragula": "^2.0.1", "ng4-click-outside": "^1.0.1", "ngx-clipboard": "^11.1.3", "ngx-contextmenu": "^5.0.2", "ngx-echarts": "^4.0.0", "ngx-filepond": "^2.0.6", "ngx-infinite-scroll": "^6.0.1", "ngx-moment": "^3.2.0", "ngx-monaco-editor": "^6.0.0", "ngx-quill": "^3.3.0", "ngx-spinner": "^6.1.2", "ngx-virtual-scroller": "^1.0.11", "quill": "^1.3.6", "rxjs": "^6.0.0", "underscore": "^1.9.1", "web-animations-js": "^2.3.1", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.6.5", "@angular/cli": "~6.0.5", "@angular/compiler-cli": "^6.0.3", "@angular/language-service": "^6.0.3", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "angular-cli": "^1.0.0-beta.28.3", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "^3.1.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "^5.4.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "~2.7.2" } }

The log given by the failure

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 'serve-local' ] 2 info using npm@5.6.0 3 info using node@v8.11.1 4 verbose run-script [ 'preserve-local', 'serve-local', 'postserve-local' ] 5 info lifecycle vizdom-web@0.0.0~preserve-local: vizdom-web@0.0.0 6 info lifecycle vizdom-web@0.0.0~serve-local: vizdom-web@0.0.0 7 verbose lifecycle vizdom-web@0.0.0~serve-local: unsafe-perm in lifecycle true 8 verbose lifecycle vizdom-web@0.0.0~serve-local: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Neurosensum\Vizdom\vizdom\vizdom-web\node_modules.bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;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\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\Java\jdk1.8.0_171\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Amazon\AWSCLI\bin\;C:\Program Files\PuTTY\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Git\cmd;C:\Users\Vibhanshu Biswas\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\Vibhanshu Biswas\AppData\Local\Programs\Python\Python37-32\;C:\Users\Vibhanshu Biswas\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Vibhanshu Biswas\AppData\Roaming\npm;C:\Users\Vibhanshu Biswas\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Vibhanshu Biswas\AppData\Local\Yarn\bin;C:\Program Files\Java\jdk1.8.0_171\bin;C:\Program Files\Java\jdk1.8.0_171;C:\Users\Vibhanshu Biswas\AppData\Local\Android\Sdk\build-tools\27.0.3; 9 verbose lifecycle vizdom-web@0.0.0~serve-local: CWD: D:\Neurosensum\Vizdom\vizdom\vizdom-web 10 silly lifecycle vizdom-web@0.0.0~serve-local: Args: [ '/d /s /c', 'ng serve --configuration=uat-local' ] 11 silly lifecycle vizdom-web@0.0.0~serve-local: Returned: code: 1 signal: null 12 info lifecycle vizdom-web@0.0.0~serve-local: Failed to exec serve-local script 13 verbose stack Error: vizdom-web@0.0.0 serve-local: ng serve --configuration=uat-local 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (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. (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 vizdom-web@0.0.0 15 verbose cwd D:\Neurosensum\Vizdom\vizdom\vizdom-web 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" "run" "serve-local" 18 verbose node v8.11.1 19 verbose npm v5.6.0 20 error code ELIFECYCLE 21 error errno 1 22 error vizdom-web@0.0.0 serve-local: ng serve --configuration=uat-local 22 error Exit status 1 23 error Failed at the vizdom-web@0.0.0 serve-local script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

Desired functionality

It should serve or build the project via the NPM RUN script command

Mention any other details that might be useful

alan-agius4 commented 5 years ago

Looks like you are two cli dependencies in your package.json which are conflicting.

"@angular/cli": "~6.0.5",
"angular-cli": "^1.0.0-beta.28.3",
cray2015 commented 5 years ago

yup you are absolutely correct. Removing the 'beta' dependency solved the issue for me!!!

Just out of curiosity, did you manually checked the package.json or was it visible in the logs? I'm asking this because so that from next time I don't have to open issues for such silly problems. I dont know from where did this dependency came from.

alan-agius4 commented 5 years ago

From the logs given it showns that something was not quite right

As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.
angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.