ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 654 forks source link

Ionic serve stops working out of nowhere #1448

Closed hounsellal closed 6 years ago

hounsellal commented 8 years ago

I have an RC0 app that was working fine last night. "ionic serve" worked fine. Now all of a sudden this morning I type "ionic serve" and it will not work. Logs:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.2.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'watch' ]
2 info using npm@3.10.8
3 info using node@v6.2.0
4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ]
5 info lifecycle ionic-hello-world@~prewatch: ionic-hello-world@
6 silly lifecycle ionic-hello-world@~prewatch: no script for prewatch, continuing
7 info lifecycle ionic-hello-world@~watch: ionic-hello-world@
8 verbose lifecycle ionic-hello-world@~watch: unsafe-perm in lifecycle true
9 verbose lifecycle ionic-hello-world@~watch: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/al/Dropbox/Development/chopchop/ionic-app/ChopChop/node_modules/.bin:/usr/local/Cellar/node/6.2.0/bin:/usr/local/share/npm/bin:/Users/al/.rbenv/shims:/Users/al/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle ionic-hello-world@~watch: CWD: /Users/al/Dropbox/Development/chopchop/ionic-app/ChopChop
11 silly lifecycle ionic-hello-world@~watch: Args: [ '-c', 'ionic-app-scripts watch' ]
12 silly lifecycle ionic-hello-world@~watch: Returned: code: 1  signal: null
13 info lifecycle ionic-hello-world@~watch: Failed to exec watch script
14 verbose stack Error: ionic-hello-world@ watch: `ionic-app-scripts watch`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:850:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid ionic-hello-world@
16 verbose cwd /Users/al/Dropbox/Development/chopchop/ionic-app/ChopChop
17 error Darwin 15.6.0
18 error argv "/usr/local/Cellar/node/6.2.0/bin/node" "/usr/local/bin/npm" "run" "watch"
19 error node v6.2.0
20 error npm  v3.10.8
21 error code ELIFECYCLE
22 error ionic-hello-world@ watch: `ionic-app-scripts watch`
22 error Exit status 1
23 error Failed at the ionic-hello-world@ watch script 'ionic-app-scripts watch'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the ionic-hello-world package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     ionic-app-scripts watch
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs ionic-hello-world
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls ionic-hello-world
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
hounsellal commented 8 years ago

Here's the output from running "ionic serve"

ionic serve

Running 'serve:before' npm script before serve
> ionic-hello-world@ watch /Users/al/Dropbox/Development/chopchop/ionic-app/ChopChop
> ionic-app-scripts watch
module.js:457
    throw err;
    ^

Error: Cannot find module '../dist/index'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/al/Dropbox/Development/chopchop/ionic-app/ChopChop/node_modules/.bin/ionic-app-scripts:19:3)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)

npm
 ERR! Darwin 15.6.0

npm ERR! argv "/usr/local/Cellar/node/6.7.0/bin/node" "/usr/local/bin/npm" "run" "watch"

npm ERR! node v6.7.0
npm 
ERR! npm  v3.10.8
npm ERR! code
 ELIFECYCLE
npm ERR! ionic-hello-world@ watch: `ionic-app-scripts watch`
npm ERR!
 Exit status 1
npm ERR! 
npm ERR!
 Failed at the ionic-hello-world@ watch script 'ionic-app-scripts watch'.
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 watch

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!     /Users/al/Dropbox/Development/chopchop/ionic-app/ChopChop/npm-debug.log

Caught exception:
 undefined 

Mind letting us know? https://github.com/driftyco/ionic-cli/issues
A-EL commented 8 years ago

+1 I have the same problem

jthoms1 commented 8 years ago

Could you provide me with the output from ionic info from within your project directory? Thanks, this should help in troubleshooting.

A-EL commented 8 years ago

I could pass this state by doing the following:

garrysaddington commented 8 years ago

+1 Cordova CLI: 6.3.1 Ionic Framework Version: 2.0.0-rc.0 Ionic CLI Version: 2.1.0 Ionic App Lib Version: 2.1.0-beta.1 ios-deploy version: Not installed ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v6.7.0 Xcode version: Xcode 8.0 Build version 8A218a

garrysaddington commented 8 years ago

Update: If I make a new project and copy the modules from there to the broken app it works. until I put my machine to sleep and wake it up. At which point the same error occurs.

garrysaddington commented 8 years ago

This is a copy of my CLI from last night and this morning. The only thing that's changed is that the machine went into lock screen when I went to bed.

Garrys-MacBook-Air-2:ScholarPack garry$ ionic serve

Running 'serve:before' npm script before serve

ionic-hello-world@ watch /Users/garry/Dropbox/MOBILE/ScholarPack ionic-app-scripts watch [18:52:46] ionic-app-scripts 0.0.28 [18:52:46] watch started ... [18:52:46] build dev started ... [18:52:46] clean started ... [18:52:46] clean finished in 17 ms [18:52:46] copy started ... [18:52:46] typescript compiler started ... [18:52:46] lint started ... [18:52:46] copy finished in 105 ms [18:52:47] lint finished in 1.34 s [18:52:52] typescript compiler ready in 6.38 s [18:52:52] bundle dev started ... [18:53:06] bundle dev finished in 13.81 s [18:53:06] sass started ... [18:53:08] sass finished in 2.05 s [18:53:08] build dev finished in 22.27 s [18:53:08] watch ready in 22.42 s Running live reload server: http://192.168.0.193:35729 Watching: www/*/, !www/lib/**/_, !www/_/.map √ Running dev server: http://192.168.0.193:8100 Ionic server commands, enter: restart or r to restart the client app from the root goto or g and a url to have the app navigate to the given url consolelogs or c to enable/disable console log output serverlogs or s to enable/disable server log output quit or q to shutdown the server and exit

ionic $ q

THIS MORNING:

Garrys-MacBook-Air-2:ScholarPack garry$ ionic serve

Running 'serve:before' npm script before serve

ionic-hello-world@ watch /Users/garry/Dropbox/MOBILE/ScholarPack ionic-app-scripts watch module.js:457 throw err; ^

Error: Cannot find module '../dist/index' at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object. (/Users/garry/Dropbox/MOBILE/ScholarPack/node_modules/.bin/ionic-app-scripts:19:3) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3)

npm ERR! Darwin 15.6.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "watch"

npm ERR! node v6.7.0 npm ERR! npm v3.10.3 npm ERR! code ELIFECYCLE

npm ERR! ionic-hello-world@ watch: ionic-app-scripts watch npm ERR! Exit status 1 npm ERR!

npm ERR! Failed at the ionic-hello-world@ watch script 'ionic-app-scripts watch'. 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 watch 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! /Users/garry/Dropbox/MOBILE/ScholarPack/npm-debug.log

Caught exception: undefined

Mind letting us know? https://github.com/driftyco/ionic-cli/issues

gnjuguna commented 8 years ago

I have the same problem. Yesterday ionic serve was working fine. Today its giving this error.

My system information:

Cordova CLI: 6.3.1 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-rc.0 Ionic CLI Version: 2.1.0 Ionic App Lib Version: 2.1.0-beta.1 ios-deploy version: 1.8.6 ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v6.5.0 Xcode version: Xcode 8.0 Build version 8A218a

sijad commented 8 years ago

I had same issue

running git clean -x -d -f; git reset --hard; npm install fixed this. BE CAREFUL DO NOT RUN IF YOU DON'T KNOW WHAT THIS COMMAND DOES!

garrysaddington commented 8 years ago

I have (so far so good) found a workaround, by deleting the node_modules and running 'npm install' in the project directory.

tezcane commented 8 years ago

Only way I could fix it (tried everything I saw in multiple forums) was to make a new project and port over code. I saw this when upgrading from Ionic RC0 to RC1.

SmallhillCZ commented 8 years ago

I have the same problem except the exit code is 137

Your system information:                                                                                                             

Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on.                                        
6.3.1                                                                                                                                

Ionic Framework Version: 2.0.0-rc.1                                                                                                  
Ionic CLI Version: 2.1.1                                                                                                             
Ionic App Lib Version: 2.1.1                                                                                                         
Ionic App Scripts Version: 0.0.36                                                                                                    
OS: Distributor ID:     Ubuntu Description:     Ubuntu 14.04 LTS                                                                     
Node Version: v6.8.1
mindware commented 7 years ago

Same issue. @garrysaddington's fix did not work for me.

PrithiviRajG commented 7 years ago

I am also facing the same issue for two days. deleting node modules and reinstalling ionic is not working and I did several times :crying_cat_face:

megharajdeepak commented 7 years ago

Same issue here as well.

ionic info: Your system information:

Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.17 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.45 ios-deploy version: Not installed ios-sim version: Not installed OS: OS X El Capitan Node Version: v7.2.1 Xcode version: Xcode 8.1 Build version 8B62

Tried deleting node_modules of the project and did npm install again. No luck. I had did option + command + delete. After that app kept giving me the error mentioned above.

jthoms1 commented 7 years ago

If you are working on an RC project please be sure to have @ionic/app-scripts installed and your package.json file.

  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },

https://github.com/driftyco/ionic-app-scripts#npm-scripts

mikewagz commented 7 years ago

I also experienced this issue after a restart. Mine had something to do with an included library:

[10:19:51] ionic-app-scripts 0.0.48 [10:19:51] ionic-app-script task: "serve" [10:19:51] Error: Cannot find module 'lodash/assign' Error: Cannot find module 'lodash/assign' at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.

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 spectora-mobile package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! ionic-app-scripts serve

Deleting the modules and doing a npm install fixed it.

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.48 ios-deploy version: 1.9.0 ios-sim version: 5.0.11 OS: OS X El Capitan Node Version: v7.2.1 Xcode version: Xcode 8.1 Build version 8B62

adirzoari commented 7 years ago

@jthoms1 i have same issue got this errors while i run ionic serve

`module.js:471 throw err; ^

Error: Cannot find module 'C:\Users\adirz\myapps\HaverSami\node_modules\ionic\bin\ionic' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3`

mfalzetta commented 7 years ago

In my case, files generated for xCode was the problem.

Im sync with git for view the differences and revert all (chages in node_module). After this wotks well.

HommyDeJ commented 7 years ago

Trying to create a project I got this error.

npm install ✖ Running command - failed! [ERROR] An error occurred while running npm install (exit code 1):

    npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
    npm WARN prefer global node-gyp@3.6.2 should be installed with -g

    > node-sass@4.5.0 install /home/hommydejesus/DenunciasApp/node_modules/node-sass
    > node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-57_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-57_binding.node":

    HTTP error 404 Not Found

    Hint: If github.com is not accessible in your location
          try setting a proxy via HTTP_PROXY, e.g.

          export HTTP_PROXY=http://example.com:1234

    or configure npm proxy via

          npm config set proxy http://example.com:8080

fsevents@1.1.1 install /home/hommydejesus/DenunciasApp/node_modules/fsevents node install

node-sass@4.5.0 postinstall /home/hommydejesus/DenunciasApp/node_modules/node-sass node scripts/build.js

    Building: /usr/bin/nodejs /home/hommydejesus/DenunciasApp/node_modules/node-gyp/bin/node-gyp.js rebuild --verbos

e --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= gyp info it worked if it ends with ok gyp verb cli [ '/usr/bin/nodejs', gyp verb cli '/home/hommydejesus/DenunciasApp/node_modules/node-gyp/bin/node-gyp.js', gyp verb cli 'rebuild', gyp verb cli '--verbose', gyp verb cli '--libsass_ext=', gyp verb cli '--libsass_cflags=', gyp verb cli '--libsass_ldflags=', gyp verb cli '--libsass_library=' ] gyp info using node-gyp@3.6.2 gyp info using node@8.0.0 | linux | x64 gyp verb command rebuild [] gyp verb command clean [] gyp verb clean removing "build" directory gyp verb command configure [] gyp verb check python checking for Python executable "python2" in the PATH gyp verb which succeeded python2 /usr/bin/python2 gyp verb check python version /usr/bin/python2 -c "import platform; print(platform.python_version());" returne d: "2.7.6\n" gyp verb get node dir no --target version specified, falling back to host node version: 8.0.0 gyp verb command install [ '8.0.0' ] gyp verb install input version string "8.0.0" gyp verb install installing version: 8.0.0 gyp verb install --ensure was passed, so won't reinstall if already installed gyp verb install version is already installed, need to check "installVersion" gyp verb got "installVersion" 9 gyp verb needs "installVersion" 9 gyp verb install version is good gyp verb get node dir target node version installed: 8.0.0 gyp verb build dir attempting to create "build" dir: /home/hommydejesus/DenunciasApp/node_modules/node-sass/buil d gyp verb build dir "build" dir needed to be created? /home/hommydejesus/DenunciasApp/node_modules/node-sass/buil d gyp verb build/config.gypi creating config file gyp verb build/config.gypi writing out config file: /home/hommydejesus/DenunciasApp/node_modules/node-sass/build /config.gypi gyp verb config.gypi checking for gypi file: /home/hommydejesus/DenunciasApp/node_modules/node-sass/config.gypi gyp verb common.gypi checking for gypi file: /home/hommydejesus/DenunciasApp/node_modules/node-sass/common.gypi gyp verb gyp gyp format was not specified; forcing "make" gyp info spawn /usr/bin/python2 gyp info spawn args [ '/home/hommydejesus/DenunciasApp/node_modules/node- gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/home/hommydejesus/DenunciasApp/node_modules/node-sass/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/home/hommydejesus/DenunciasApp/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/hommydejesus/.node-gyp/8.0.0/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/hommydejesus/.node-gyp/8.0.0', gyp info spawn args '-Dnode_gyp_dir=/home/hommydejesus/DenunciasApp/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/hommydejesus/.node-gyp/8.0.0/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/home/hommydejesus/DenunciasApp/node_modules/node-sass', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' ] gyp verb command build [] gyp verb build type Release gyp verb architecture x64 gyp verb node dev dir /home/hommydejesus/.node-gyp/8.0.0 gyp verb which succeeded for make /usr/bin/make gyp info spawn make gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ] make: Entering directory /home/hommydejesus/DenunciasApp/node_modules/node-sass/build' g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.5.0.beta.2"' -I/home/hommydejesus/.node-gyp/8.0.0/ include/node -I/home/hommydejesus/.node-gyp/8.0.0/src -I/home/hommydejesus/.node-gyp/8.0.0/deps/uv/include -I/home/hommy dejesus/.node-gyp/8.0.0/deps/v8/include -I../src/libsass/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m6 4 -O3 -fno-omit-frame-pointer -std=gnu++0x -std=c++0x -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/li bsass/src/libsass/src/ast.o.d.raw -c -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp make: g++: Command not found make: *** [Release/obj.target/libsass/src/libsass/src/ast.o] Error 127 make: Leaving directory/home/hommydejesus/DenunciasApp/node_modules/node-sass/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/home/hommydejesus/DenunciasApp/node_modules/node-gyp/lib/build.js:25 8:23) gyp ERR! stack at emitTwo (events.js:125:13) gyp ERR! stack at ChildProcess.emit (events.js:213:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12) gyp ERR! System Linux 4.4.0-78-generic gyp ERR! command "/usr/bin/nodejs" "/home/hommydejesus/DenunciasApp/node_modules/node-gyp/bin/node-gyp.js" "rebu ild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /home/hommydejesus/DenunciasApp/node_modules/node-sass gyp ERR! node -v v8.0.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok Build failed with error code: 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.5.0 postinstall: node scripts/build.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass@4.5.0 postinstall script. npm ERR! Failed at the node-sass@4.5.0 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    ┌────────────────────────────────────────────────────────────────┐
    │                    npm update check failed                     │
    │              Try running with sudo or get access               │
    │              to the local update config store via              │
    │ sudo chown -R $USER:$(id -gn $USER) /home/hommydejesus/.config │
    └────────────────────────────────────────────────────────────────┘

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/hommydejesus/.npm/_logs/2017-06-02T14_44_29_769Z-debug.log
HommyDeJ commented 7 years ago

Andd, another error when I try to run the ionic serve command

hommydejesus@Hommy-PC:~/DenunciasApp$ ionic serve ? Looks like this is an Ionic Angular project, would you like to install @ionic/cli-plugin-ionic-angular and continue? Y es

npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest ✔ Running command - done! Error: Cannot find module '@ionic/app-scripts'

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue appears to be associated with an old version of the Ionic CLI. Please update to the latest CLI version, which supports all versions of the Ionic Framework. If the issue is relevant and if it persists after updating to the latest CLI version, please create a new issue.

Thank you for using Ionic!