Ionic-cli: Ionic4 4.2.1 : Linux can't run "ionic serve" without an error

Created on 19 Oct 2018  Â·  12Comments  Â·  Source: ionic-team/ionic-cli

I am struggling in this error when I try the first run on an Ionic4 project.
when I try "ionic serve" I'm getting this error:
```
ng run app:serve --host=0.0.0.0 --port=8100
[ERROR] ng has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.

I didn't change anything in the project, just created and tried to run. I tried in Windows and it works like a charm, but I can't make it run on Linux. I tried other computers and I am getting the same error, what makes me believe there is a bug in ionic cli when running it in linux OR I should make some changes in linux to make it run.

When I run "ionic serve --verbose" I get this error "detail":
![image](https://user-images.githubusercontent.com/19226926/47219929-a4dfaa00-d386-11e8-92c1-b88a3caaa1b5.png)

This my Ionic Info:

Ionic:

ionic (Ionic CLI) : 4.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.13
@angular-devkit/build-angular : 0.8.5
@angular-devkit/schematics : 0.8.5
@angular/cli : 6.2.5
@ionic/angular-toolkit : 1.0.0

Cordova:

cordova (Cordova CLI) : not installed
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)

System:

NodeJS : v10.12.0 (/snap/node/1149/bin/node)
npm : not installed
OS : Linux 4.15
```

Although it is saying that npm and Cordova are not installed, they are installed, at least if I run "npm --version" it returns to me with "6.4.1" and cordova "8.1.2 ([email protected])".

Ionic3 projects is running smoothly.

triage

Most helpful comment

@davidrock What happens if you run npx ng serve?

All 12 comments

@davidrock What happens if you run npx ng serve?

@dwieeb yeah! It's working! But... why? I had to install npx ( "sudo npm install -g npx" ), but it's working. Why is this happening? It's a bug on ionic cli ?

Getting the same build failure with ionic serve and npx ng serve, can be reproduced with a brand new ionic start.

ERROR in ./src/global.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/global.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
TypeError: Cannot read property 'split' of undefined
    at getRenderFuncFromSassImpl (/Users/shawn/Documents/dev/Paylocity/ionic4/TestIonic4/node_modules/sass-loader/lib/loader.js:88:29)
    at Object.sassLoader (/Users/shawn/Documents/dev/Paylocity/ionic4/TestIonic4/node_modules/sass-loader/lib/loader.js:46:20)
ERROR in ./src/theme/variables.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/theme/variables.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
TypeError: Cannot read property 'split' of undefined
    at getRenderFuncFromSassImpl (/Users/shawn/Documents/dev/Paylocity/ionic4/TestIonic4/node_modules/sass-loader/lib/loader.js:88:29)
    at Object.sassLoader (/Users/shawn/Documents/dev/Paylocity/ionic4/TestIonic4/node_modules/sass-loader/lib/loader.js:46:20)

Ionic:

ionic (Ionic CLI) : 4.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.13
@angular-devkit/build-angular : 0.8.6
@angular-devkit/schematics : 0.8.6
@angular/cli : 6.2.6
@ionic/angular-toolkit : 1.0.0

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)

System:

ios-deploy : 1.9.2
ios-sim : 5.0.8
NodeJS : v8.11.2 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255

@ucswift seems like a different issue. Try run "npm cache clean" and "npm install" before.
But I recommend you to create a separated issue for this, you'll probably get more help.

@davidrock yea, initially it looked like the same error but with npx ng serve working for you doesn't look like it. I've created issue #3702 to see what else might be up. Npm cache clean, update npm install don't see to fix the issue, but thanks for the suggestion.

@davidrock I'm not sure. For some reason the Angular CLI is exiting immediately with an error when run as a subprocess of the Ionic CLI. Could you also try to run this?

./node_modules/.bin/ng run app:serve

I have the same problem, is there a solution?
To use the "ionic serve" normally?

I have the same problem, is there a solution?

Try this: $ npm install
$ npm audit fix

I have the same problem, is there a solution?

For me the solution was to use "npx ng serve"
This is an old issue, but I think that I solve that fixing the node version too, I managed to get over it using "nvm" to use the right node version for the project.

Thanks #davidrock

From: David Rock
Sent: 23 February 2019 01:58
To: ionic-team/ionic-cli
Cc: siva678; Comment
Subject: Re: [ionic-team/ionic-cli] Ionic4 4.2.1 : Linux can't run "ionicserve" without an error (#3697)

I have the same problem, is there a solution?
For me the solution was to use "npx ng serve"
This is an old issue, but I think that I solve that fixing the node version too, I managed to get over it using "nvm" to use the right node version for the project.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

i have same error, how to solve it?

Was this page helpful?
0 / 5 - 0 ratings