Ionic-cli: Ionic serve fails (rc4)

Created on 20 Dec 2016  路  4Comments  路  Source: ionic-team/ionic-cli

Short description of the problem:

When I try to run ionic serve, it fails. It was working before. My doubt is probably with the latest update.

What behavior are you expecting?

To run without errors

This is the error/output I get

> ionic-hello-world@ ionic:serve /home/murshid/Documents/Ionic/CalConnectV2
> ionic-app-scripts serve "--lab"

[12:00:26]  ionic-app-scripts 0.0.47 
[12:00:26]  watch started ... 
[12:00:26]  build dev started ... 
[12:00:26]  clean started ... 
[12:00:26]  clean finished in 4 ms 
[12:00:26]  copy started ... 
[12:00:26]  transpile started ... 
[12:00:30]  transpile finished in 3.60 s 
[12:00:30]  webpack started ... 
[12:00:30]  copy finished in 3.82 s 
/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:95
          var code = nextLine.substr(0, mapping.generatedColumn -
                             ^

TypeError: Cannot read property 'substr' of undefined
    at Function.<anonymous> (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:95:30)
    at Array.forEach (native)
    at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:155:14)
    at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:80:24)
    at SourceMapSource.node (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/lib/SourceMapSource.js:42:20)
    at ReplaceSource.node (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/lib/ReplaceSource.js:66:29)
    at CachedSource.node (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/lib/CachedSource.js:12:23)
    at /home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/lib/ConcatSource.js:40:49
    at Array.map (native)
    at ConcatSource.node (/home/murshid/Documents/Ionic/CalConnectV2/node_modules/webpack-sources/lib/ConcatSource.js:39:60)

npm ERR! Linux 4.4.0-53-generic
npm ERR! argv "/home/murshid/.nvm/versions/node/v7.2.1/bin/node" "/home/murshid/.nvm/versions/node/v7.2.1/bin/npm" "run" "ionic:serve" "--" "--lab"
npm ERR! node v7.2.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ ionic:serve: `ionic-app-scripts serve "--lab"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ionic-hello-world@ ionic:serve script 'ionic-app-scripts serve "--lab"'.
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 ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts serve "--lab"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/murshid/Documents/Ionic/CalConnectV2/npm-debug.log
There was an error serving your Ionic application: There was an error with the spawned command: serve

My ionic info:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v7.2.1
Xcode version: Not installed

Most helpful comment

"ionic_cleancss": "./config/cleancss.config.js" only for custom config cleancss.

For default configuration, that is enough for me:

"config": {
    "ionic_bundler": "rollup",
    "ionic_source_map_type": "source-map"
}

All 4 comments

For me, that solved it.

1) In package.js, update the app-scripts

"@ionic/app-scripts": "0.0.48"

2) Also in package.js, add or overwrite:

"config": {
    "ionic_bundler": "rollup",
    "ionic_source_map_type": "source-map",
    "ionic_cleancss": "./config/cleancss.config.js"
 }

Get cleancss.config.js at https://github.com/driftyco/ionic-app-scripts/tree/master/config

3) Clean node_modules folder

$ rm -rf node_modules

4) Reinstall the dependencies from package.json

$ npm install

5) Run ionic serve

$ ionic serve

Ionic App Scripts
https://github.com/driftyco/ionic-app-scripts

Ionic App Scripts changelog
https://github.com/driftyco/ionic-app-scripts/blob/master/CHANGELOG.md

Enjoy :)

Has worked for me. Thank you!

"ionic_cleancss": "./config/cleancss.config.js" only for custom config cleancss.

For default configuration, that is enough for me:

"config": {
    "ionic_bundler": "rollup",
    "ionic_source_map_type": "source-map"
}

Thanks, This works.

Was this page helpful?
0 / 5 - 0 ratings