Ionic-framework: RC4 fails to build with an error in source-node.js:95

Created on 16 Dec 2016  路  10Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request

Current behavior:

ionic-build and ionic-serve result in a CLI error.

Expected behavior:

ionic-build and ionic-serve should build and serve the app (respectively) as expected.

Steps to reproduce:

coreymcmahon at Coreys-MacBook-Pro in ~/Sites/ionic-app on feature/rc4 [!$]
$ /usr/local/Cellar/nvm/0.31.0/versions/node/v6.9.2/bin/ionic build

> ionic-app@ ionic:build /Users/coreymcmahon/Sites/ionic-app
> ionic-app-scripts build

[15:49:14]  ionic-app-scripts 0.0.47 
[15:49:14]  build dev started ... 
[15:49:14]  clean started ... 
[15:49:14]  clean finished in 4 ms 
[15:49:14]  copy started ... 
[15:49:14]  transpile started ... 
[15:49:19]  transpile finished in 4.51 s 
[15:49:19]  webpack started ... 
[15:49:19]  copy finished in 4.87 s 
/Users/coreymcmahon/Sites/ionic-app/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> (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:95:30)
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:155:14)
    at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:80:24)
    at SourceMapSource.node (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/lib/SourceMapSource.js:42:20)
    at ReplaceSource.node (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/lib/ReplaceSource.js:66:29)
    at CachedSource.node (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/lib/CachedSource.js:12:23)
    at /Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/lib/ConcatSource.js:40:49
    at Array.map (native)
    at ConcatSource.node (/Users/coreymcmahon/Sites/ionic-app/node_modules/webpack-sources/lib/ConcatSource.js:39:60)

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/nvm/0.31.0/versions/node/v6.9.2/bin/node" "/usr/local/opt/nvm/versions/node/v6.9.2/bin/npm" "run" "ionic:build" "--"
npm ERR! node v6.9.2
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! ionic-app@ ionic:build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ionic-app@ ionic:build script 'ionic-app-scripts build'.
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-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ionic-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/coreymcmahon/Sites/ionic-app/npm-debug.log

Other information:

App was building as expected before doing the RC4 upgrade (we were using RC3).

Ionic info:

$ /usr/local/Cellar/nvm/0.31.0/versions/node/v6.9.2/bin/ionic info

Your system information:

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: 1.8.6 
ios-sim version: 5.0.8 
OS: OS X El Capitan
Node Version: v6.9.2
Xcode version: Xcode 8.1 Build version 8B62

Most helpful comment

+1 here

I'm not sure what the root cause is here, but I hacked around this by editing the file in node_modules directly and just adding a return statement before the failing line:

node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:95

Obviously this isn't a long-term fix, but good enough to get things building again.
@herbzi

Confirmed. A workaround to get it working for now is just add an if on line 95

var nextLine = remainingLines[0];
if (!nextLine) return;

All 10 comments

Getting the same error

EDIT: Further investigation shows, that ionic serve --prod completes just fine, but still says build dev finished in ... which is probably correct, sine i dont think there even exists a prod mode for serve. So my temporary fix for this is to serve/build everthing with --prod flag.

Also, npm gives error

npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\MyPC\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js"
 "run" "ionic:serve" "--"

which shows empty -- flag. Could it be that a parameter is always expected?

I'm not sure what the root cause is here, but I hacked around this by editing the file in node_modules directly and just adding a return statement before the failing line:

node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:95

Obviously this isn't a long-term fix, but good enough to get things building again.

dup: https://github.com/driftyco/ionic-app-scripts/issues/562
I can run ionic rc4 with app scripts .46 without any issue. But .47 brings up this error.

Updated:
RESOLVED: I installed node and Ionic from scratch

Similar error. To be sure, just after I updated to RC4 I run "ionic start NewAppTest blank --v2
I got a warning:

Installing npm packages...
npm WARN peerDependencies The peer dependency @angular/tsc-wrapped@* included from @ionic/app-scripts will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency rxjs@* included from @ionic/app-scripts will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN optional dep failed, continuing [email protected]

and then, if I run ionic serve I get:

Binary is fine; exiting.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.6.1
npm ERR! npm  v2.15.9
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/[email protected] wants [email protected]

npm ERR! Please include the following file with any support request:
npm ERR!     S:\IonicProject\ListaSpesa\npm-debug.log
Error with start undefined
Error Initializing app: There was an error with the spawned command: npminstall
There was an error with the spawned command: npminstall

RESOLVED: I installed node and Ionic from scratch

+1 here

I'm not sure what the root cause is here, but I hacked around this by editing the file in node_modules directly and just adding a return statement before the failing line:

node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:95

Obviously this isn't a long-term fix, but good enough to get things building again.
@herbzi

Confirmed. A workaround to get it working for now is just add an if on line 95

var nextLine = remainingLines[0];
if (!nextLine) return;

I was facing the same issue and isolated the problem to multiple components within same .ts file. in my RC3 project.

Update: More specifically this occurs when the second component within the .ts file uses a _templateUrl_ as opposed to _template_ for its decoration.

Applied the single responsibility principle from Angular and separated the components into their respective .ts files to resolve the original issue reported here.

https://angular.io/docs/ts/latest/guide/style-guide.html#!#single-responsibility

I was able to narrow down the issue by manually migrating old rc3 project (part by part) to a freshly created rc4 project.!!!

Maybe the experts can confirm.

Confirmed. After a refact of my code and doing a fresh install, I don't need more the workaround above

I can not tell for sure what the problem was, but I just split everything into components and providers and booom

This issue was moved to driftyco/ionic-app-scripts#593

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings