ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 304 forks source link

RC4 fails to build with an error in source-node.js:95 #593

Closed jgw96 closed 7 years ago

jgw96 commented 7 years ago

From @coreymcmahon on December 16, 2016 5:0

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

Copied from original issue: driftyco/ionic#9658

jgw96 commented 7 years ago

From @coreymcmahon on December 16, 2016 5:12

Potentially related to the same bug here: https://github.com/angular/angular-cli/commit/22a6b59dd429356bd617ae3dfceb51335aa815d2

jgw96 commented 7 years ago

From @themastersoda on December 16, 2016 8:0

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?

jgw96 commented 7 years ago

From @coreymcmahon on December 16, 2016 9:2

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.

jgw96 commented 7 years ago

From @herbzi on December 16, 2016 12:5

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.

jgw96 commented 7 years ago

From @pimol on December 16, 2016 16:4

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 fsevents@1.0.15

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 rxjs@5.0.0-beta.12 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/core@2.2.1 wants rxjs@5.0.0-beta.12

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

jgw96 commented 7 years ago

From @st1s on December 16, 2016 16:39

+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;
jgw96 commented 7 years ago

From @parkbytes on December 17, 2016 17:38

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.

jgw96 commented 7 years ago

From @st1s on December 18, 2016 22:4

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

AlGantori commented 7 years ago

Duh! a fresh install means exactly what commands

AlGantori commented 7 years ago

npm install npm@latest -g ???

jamespacileo commented 7 years ago

@AlGantori I think he means a fresh ionic app, anyway having only 1 Component with templateUrl per file seems to temporarily fix it.

If this is intended there should probably be a humanised error message, prob an issue to raise with Angular.

escobara commented 7 years ago

Thanks @jgw96, Inlining the second template in the component file removed the source-node error

Yimiprod commented 7 years ago

@jgw96 what do you mean when you say fresh install ?

JLNNN commented 7 years ago

+1 (I got the same error on RC5)

danbucholtz commented 7 years ago

I believe this is resolved with 1.0.0. Can you please let me know if it's not? I have never been able to recreate.

Thanks, Dan

alexanderwilkie commented 7 years ago

Easy to reproduce in a fresh install of 2.0.0 just today - create a .ts with two @Component defined - both of which with a templateUrl defined - splitting them out into two files resolves it.

BatStak commented 7 years ago

@alexanderwilkie This error was driving me crazy until today (RC4, RC5 and 2.0.0). Doing @jgw96 edits everytime. I split all my components and errors are gone. Good for futures packages updates.

EDIT : I delete node_modules folder and reinstall all with npm install to check

danbucholtz commented 7 years ago

Ahhh, okay, nice, good catch!

Thanks, Dan

robshep commented 7 years ago

Confirmed still an issue.

To reproduce, create two components in the same file. (for me a Page, and then a small Modal Pane) both with templateUrl.

Splitting the modal into it's own definition typescript file is the workaround, but would be nice to get these components next to each other in the same source.

Ionic Framework: 2.0.0
Ionic Native: 2.4.1
Ionic App Scripts: 1.0.0
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.9.5
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
mariohmol commented 7 years ago

had the same issue today.. shouldnt this issue be opened?

robrothedev commented 7 years ago

I also experienced this working with the ModalController in Ionic and had two components in one file as @robshep experienced. I created a separate file for the Modal component and it resolved my issue.

mastronaute commented 7 years ago

Same here with 3.1.2

Quixotical commented 7 years ago

same here with 3.4.0

but good to know it can be fixed by just splitting everything out into its own file