Giter Site home page Giter Site logo

cordova-plugin-browsersync's Introduction

Cordova Browser-Sync Plugin

dependencies Status devDependencies Status

Integrating BrowserSync into your Cordova workflow.

  • Watch files in the www folder and automatically reload HTML and CSS in all connected devices
  • Use BrowserSync's dashboard to control devices and reload them.
  • Synchronize scrolls, clicks and form inputs across multiple devices.
  • Supports real devices and emulators for iOS and Android platforms

Demo

Here is a blog post explaining the plugin and its internals.

Cordova Browser-Sync Plugin demo video

Usage

There are three ways to use the code in this plugin. Ensure that you have added the ws: and unsafe-inline CSP policies to your default-src section of the CSP meta tag (<meta content=...>) in index.html file.

Note that a -- --live-reload may need to be passed to cordova run command.

The presence of this --live-reload flag triggers the live reload workflow. Without this flag, the project remains unchanged. This way, the plugin does not have to be removed before packaging it for final deployment.

As a Cordova plugin (easiest)

This simplest way to integrate this in your Cordova workflow is to add it as a plugin

cordova plugin add cordova-plugin-browsersync

and then run run the cordova with cordova run -- --live-reload.

Note

If you ran into the error like below when you executed "cordova plugin add cordova-plugin-browsersync" command,

Failed to install 'cordova-plugin-browsersync': Error: Cannot find module 'npm'

Please try to upgrade npm command version which is your system global installed with following command.

npm install -g npm

I have not confirmed anything, but this error can be caused by a version of the npm module that is mismatched between globally installed and locally installed on the project.

As a Cordova project hook

Clone this repo and run npm run createHook to get a after_prepare.js. Add this file as an after_prepare hook to your config.xml. For example:

<hook type="after_prepare" src="scripts/after_prepare.js" />

Integrate into your workflow

You can also require('cordova-plugin-browsersync') in your node module and use the changeHost function and browserSyncServer directly in your existing workflow.

Options

Ignoring files

In many cases other hooks may copy over JS, CSS or image assets into folders like www\lib, typically from locations like bower_components. These hooks may run at after_prepare and hence should be ignored in the live reload workflow. To achieve this, run the command as

cordova run -- --live-reload --ignore=lib/**/*.*

The --ignore commands takes an anymatch compatible destination relative to the www folder.

Setting custom hostname

Sometimes, depending on your network, your OS will report multiple external IP addresses. If this happens, by default browsersync just picks the first one and hopes for the best.

To override this behaviour and manually select which host you want to use for the external interface, use the --host option, for example:

cordova run -- --live-reload --host=192.168.1.1

Setting custom port

If you need to forward ports from your local computer to the device because the device is not in the same network as your device then you may getting an error or red circle. If this happens the problem could be the 3000 port. Then you can try another one for example 8090 which should work then.

cordova run -- --live-reload --port=8090

Setting custom index file

If you do not have "index.html" in your config.xml under content node then you need to set this option to the value. Please use the --index option.

cordova run -- --live-reload --index=content.html

Enable https

If you need https you can enable it with this option. You can use --https for example.

cordova run -- --live-reload --https

cordova-plugin-browsersync's People

Contributors

awwong1 avatar axemclion avatar csantanapr avatar dpa99c avatar dusanmiloradovic avatar fdim avatar interone-ms avatar jinbe0 avatar jsakamoto avatar luposlip avatar masakura avatar nitinsurana avatar patrickbussmann avatar rburgst avatar schlep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-browsersync's Issues

Error: gap_init:2

This alert has shown up to me after reloading app or update data and browser-sync update my page what should I do to remove it
2015-11-18 17-44-22 iphone 6 - iphone 6 ios 9 1 13b137

opts.forEach is not a function

Following your video directly and I can't do

cordova run

It says:

ERROR running one or more of the platforms: TypeError: opts.forEach is not a function
You may not have the required environment or OS to run this project

Any ideas?

Cordova CLI: 5.4.0
Gulp version:  CLI version 3.9.0
Gulp local:  
ios-deploy version: 1.8.2 
ios-sim version: 5.0.3 
OS: Mac OS Yosemite
Node Version: v4.2.1
Xcode version: Xcode 7.1 Build version 7B91b 

Can't find loadash

I'm trying to use the plugin, but I'm getting this error instead.
I also tryed some variations:
without "browser" and I've made a change in my webpack config, but it doesn't work either.

My dev env
webpack
react
browsersync
cordova

$ cordova run browser -- --live-reload
Error: Cannot find module 'lodash/object/assign'

Which plugin version to install

Hello,

I noticed some inconsistencies in the versioning of the plugin.

According to this repository the latest version is 0.1.7 but in the npm registry the latest published version is the version 1.1.0 - which one is the correct one? The version 1.1.0 (at least for me) did not work as shown in your video.

It seems like the when running cordova run browser -- --live-reload it does start the normal dev sever on port 8000 and the live reload server on port 8002 and 3001.

From the log:

[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:8002
    External: http://172.27.218.31:8002
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://172.27.218.31:3001

In the end no browser is able to connect and thus live reloading does work...

Thanks in advance

Installation failure (but plugin still works)

This breaks the install (and hence platform add/remove), however it still works after it has installed

~/data/work/watchem/WatchEm/frontend$ cordova plugin add cordova-plugin-browsersync
Installing "cordova-plugin-browsersync" for android
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/cacache requires glob@'^7.1.2' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/flush-write-stream requires readable-stream@'^2.0.4' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/from2 requires readable-stream@'^2.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/globule requires glob@'~7.1.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/init-package-json requires glob@'^7.1.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/node-gyp requires glob@'^7.0.3' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/pacote requires glob@'^7.1.2' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/pacote requires safe-buffer@'^5.1.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/safe-buffer,
npm WARN unmet dependency which is version 5.0.1
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/parallel-transform requires readable-stream@'^2.1.5' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/read-package-json requires glob@'^7.1.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/sass-graph requires glob@'^7.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/sha requires readable-stream@'^2.0.2' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/ssri requires safe-buffer@'^5.1.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/safe-buffer,
npm WARN unmet dependency which is version 5.0.1
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/stream-iterate requires readable-stream@'^2.1.5' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/@ionic/cli-utils requires chalk@'^2.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/chalk,
npm WARN unmet dependency which is version 1.1.3
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/@ionic/cli-utils requires semver@'^5.4.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/semver,
npm WARN unmet dependency which is version 5.3.0
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/@ionic/cli-utils requires string-width@'^2.1.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/string-width,
npm WARN unmet dependency which is version 1.0.2
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/@ionic/cli-utils requires strip-ansi@'^4.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/strip-ansi,
npm WARN unmet dependency which is version 3.0.1
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/@ionic/cli-utils requires wrap-ansi@'^3.0.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/wrap-ansi,
npm WARN unmet dependency which is version 2.1.0
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/babel-cli requires glob@'^7.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/rimraf requires glob@'^7.0.5' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/webpack requires acorn@'^5.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/acorn,
npm WARN unmet dependency which is version 1.2.2
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/webpack requires ajv@'^5.1.5' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/ajv,
npm WARN unmet dependency which is version 4.11.8
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/webpack requires supports-color@'^4.2.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/supports-color,
npm WARN unmet dependency which is version 4.0.0
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/webpack requires yargs@'^8.0.2' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/yargs,
npm WARN unmet dependency which is version 7.1.0
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/archiver requires glob@'^7.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/archiver-utils requires glob@'^7.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/node-sass requires glob@'^7.0.3' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/tslint requires glob@'^7.1.1' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/glob,
npm WARN unmet dependency which is version 5.0.15
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/duplexify requires readable-stream@'^2.0.0' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/mississippi/node_modules/through2 requires readable-stream@'^2.1.5' but will load
npm WARN unmet dependency /home/mark/data/work/watchem/WatchEm/frontend/node_modules/readable-stream,
npm WARN unmet dependency which is version 1.0.34
Failed to install 'cordova-plugin-browsersync': Error: The package [email protected] does not satisfy its siblings' peerDependencies requirements!
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/lib/install.js:125:32
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/lib/install.js:268:7
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:142:5
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
    at cb (/home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
    at cb (/home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
    at cb (/home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
    at /home/mark/.npm/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
Error: The package [email protected] does not satisfy its siblings' peerDependencies requirements!

Having opts.forEach error

ERROR running one or more of the platforms: TypeError: opts.forEach is not a function
You may not have the required environment or OS to run this project

reloading is very slow

Each app reloading takes 60-200 secs.
Platform: Android
Browser: Chrome, version: 50.0.2661.86
Tested on many devices with same result.

Error displayed when installing the plugin

I run $ cordova platform add android:

Failed to install 'cordova-plugin-browsersync': Error: The package [email protected] does not satisfy its siblings' peerDependencies requirements!
    at /usr/local/lib/node_modules/cordova/node_modules/npm/lib/install.js:125:32
    at /usr/local/lib/node_modules/cordova/node_modules/npm/lib/install.js:268:7
    at /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:142:5
    at /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
    at cb (/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
    at /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
    at cb (/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
    at /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14
    at cb (/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
    at /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/read-installed/read-installed.js:263:14

Use common npm sub-module for the utility functions needed for browsersync on cordova

I recently factored out the utility functions needed to enable browersync on cordova into a separate github repo and npm module (https://github.com/PointSource/cordova-browsersync-primitives). These are the functions to add CSP, fix ATS, etc. I did this because I need these functions for a project I'm working on, and I know there are also 2 existing projects that also use them (https://github.com/nparashuram/cordova-plugin-browsersync and https://github.com/Microsoft/TACO).

The purpose of this issue is to suggest that we consolidate around 1 implementation of these utility functions that we can all pull in as an npm submodule.

@axemclion, what's your opinion of converting over to use a common implementation?

webpack integration

I wish to integrate this in react.
Do you have an example how to trigger the app from webpack?
I mean i've Browsersync running on webpack but the app does not respond to changes because i just used "cordova run" to start the emulator without the --live-reload option.
I need "cordova run" to quit as soon the emulator start because is webpack providing the compilation.

Help couldn't get this to work.

Hello Everyone,
Trying to figure out what I'm doing wrong but i can't get this plugin to work at all. I did tried the first installation and when I do the --live-reload

`[BS] Access URLs:


   Local: http://localhost:3001
External: http://

      UI: http://localhost:3002

UI External: http://


[BS] Serving files from: platforms/android/assets/www
[BS] Serving files from: platforms/ios/www
[BS] Watching files...`

ends with the following
`** BUILD SUCCEEDED **

No target specified for emulator. Deploying to iPhone-6s-Plus, 9.3 simulator
io.cordova.hellocordova: 15648
`

however nothing is running on localhost:3001 or 3002

Option for https

Since there where some changes in policy and some features dont work on insecure origins it would be awesome to have some flag for using secured connection with browsersync server.

Regards.

New release please

The latest release is last year. Several functions have been committed, so I want a new release.

cordova-plugin-browsersync breaks literally *everything*.

Love this plugin, but had a nightmare experience with it where it directly forced me to uninstall/reinstall Node.js/npm multiple times via brew. I was up until 4am last night dealing with it, all while trying to meet a deadline. I'd love to help fix the error, but for now, I'm just doing my due diligence to report it.

It's all related to npm's "ansistyles".

After installing cordova-plugin-browsersync, all it takes is attempting to cordova run, etc. for all hell to break loose.

alec:BLEapp alec$ cordova platform add browser
Using cordova-fetch for cordova-browser@~5.0.1
(node:1113) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Failed to fetch platform cordova-browser@~5.0.1
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 254 Error output:
npm WARN [email protected] No repository field.

npm ERR! path /Users/alec/Desktop/BLEapp/node_modules/npm/node_modules/ansistyles
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/alec/Desktop/BLEapp/node_modules/npm/node_modules/ansistyles' -> '/Users/alec/Desktop/BLEapp/node_modules/npm/node_modules/.ansistyles.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
(node:1113) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
alec:BLEapp alec$ cordova run -- -live-reload
(node:1118) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: No platforms added to this project. Please use `cordova platform add <platform>`.
(node:1118) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

After recieving this error, it breaks pretty much anything related to installing from npm, Cordova, etc. I tried reinstall "ansistyles", etc. to no avail.

For anybody else having this issue, reinstall node via brew a few times. It does the trick.

I'm on macOS 10.13.2.

Have a great day!

npm version conflict

When running cordova prepare I run into the following issue.

I think is due to a different npm version being included along with this project. I really like this plugin but this prevents me from running cordova normally.

Should npm dependency be remove from this plugin?

$ npm run cordova -- prepare

> [email protected] cordova /Users/mr155795/git/myservice2-ng
> cordova "prepare"

Discovered platform "android@^6.2.3" in config.xml or package.json. Adding it to the project
Error: Cannot find module 'npm'
Discovered platform "browser@^4.1.0" in config.xml or package.json. Adding it to the project
Error: Cannot find module 'npm'
Discovered platform "ios@^4.4.0" in config.xml or package.json. Adding it to the project
Error: Cannot find module 'npm'
Error: No platforms added to this project. Please use `cordova platform add <platform>`.

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cordova" "--" "prepare"
npm ERR! node v6.9.4
npm ERR! npm  v4.1.1
npm ERR! code ELIFECYCLE
npm ERR! [email protected] cordova: `cordova "prepare"`
npm ERR! Exit status 1

Files not being watch when --ignore not passed, no fixed on npm, but fixed in git

Problem is fixed in copy in git but the code published on npm is different.

on NPM 0.0.3

bs.watch(www + '/**/*.*', {
        ignored: www + '/' + opts.ignore
    }, function(event, files) {

when opts.ignore is undefined watch doesn't work,
code in git repo is fixed, just need to upload to npm

bs.watch(www + '**/*.*', opts.ignore ? {
        ignored: www + '/' + opts.ignore
    } : {}, function(event, files) {

Can't install cordova-plugin-browsersync

Hii there,

I've tried installing this plugin using: cordova plugin add cordova-plugin-browsersync

but I get this error every single time:

(node:15472) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to fetch plugin cordova-plugin-browsersync via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: cmd: Command failed with exit code 4294963238 Error output:
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: cordova-serve@file:file:tools\cordova-serve-2.0.0.tgz (node_modules\cordova-browser\node_modules\cordova-serve):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, stat 'C:\Users\Aroop\Documents\Git\MijnBoodschappen\file:tools\cordova-serve-2.0.0.tgz'

npm ERR! path C:\Users\Aroop\Documents\Git\MijnBoodschappen\file:cordova-dist\tools\cordova-common-2.2.0.tgz
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall stat
npm ERR! enoent ENOENT: no such file or directory, stat 'C:\Users\Aroop\Documents\Git\MijnBoodschappen\file:cordova-dist\tools\cordova-common-2.2.0.tgz'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aroop\AppData\Roaming\npm-cache\_logs\2018-02-08T12_22_30_718Z-debug.log
(node:15472) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any ideas?

Could not connect to the browser-sync server..

The initial view when browser sync starts says:

cordova-plugin-browsersync

LOCAL http://localhost:3000/platforms/browser/www/index.html ❌
EXTERNAL http://192.168.1.34:3000/platforms/browser/www/index.html ❌
Could not connect to the browser-sync server. 
Check if you can access any of the

On the local browser clicking either of LOCAL or EXTERNAL will successfully start to sync. On my physical iOS device this worked a couple of day ago without the same above screen, but now shows this screen as well on iOS, and clicking neither of the two options does anything. (Nvm, this was due to different WiFi)

Any clue what's going on here - why is it showing those two options on startup of local browser?

Update NPM Package

Please Update the npm package with npm publish
the latest Version is 1.1.0 --> 2017-09-14 ('1.1.0': '2017-09-14T13:56:44.866Z')
but in git the latest version is 0.1.8

image

Installation fails

I cannot install the plugin. It makes my cordova prepare to crash..

> npx cordova prepare
Discovered platform "android@^6.2.3" in config.xml or package.json. Adding it to the project
Using cordova-fetch for cordova-android@^6.2.3
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: fr.me.myproj
	Name: Cheval
	Activity: MainActivity
	Android target: android-25
Subproject Path: CordovaLib
Android project created with [email protected]
Discovered plugin "cordova-plugin-browsersync" in config.xml. Adding it to the project
Installing "cordova-plugin-browsersync" for android
Error: Cannot find module '/Users/me/myproj/node_modules/npm/lib/build.js'

Plugin fails to start correctly

After running cordova run ios -- --live-reload brower-sync seems to start ok but right after an error is logged and the server fails to start.

[xmldom error]  element parse error: Error: invalid tagName:^���Y�-
@#[line:4,col:107]
Error: Cannot read property 'nodeName' of null

screen shot 2016-04-17 at 01 37 55

Failed to install 'cordova-plugin-browsersync

$ cordova plugin add cordova-plugin-browsersync
Plugin "cordova-plugin-browsersync" already installed on android.
Installing "cordova-plugin-browsersync" for browser
Failed to install 'cordova-plugin-browsersync': Error: Cannot find module 'npm'

Installation to cordova project was fail. ("Error: Cannot find module 'npm'")

Environment

  • OS - Windows10 Pro v.10.0.16299.192
  • node.js - v.8.9.3
  • npm - v.5.5.1
  • cordova - v.8.0.0

After cordova create ..., and installed "browser" and "android" platforms.

What's happen?

When I execute the command as following,

> cordova plugin add cordova-plugin-browsersync

the command reported the error as follows.

Installing "cordova-plugin-browsersync" for browser
Failed to install 'cordova-plugin-browsersync': Error: Cannot find module 'npm'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Context.requireCordovaModule (C:\Users\j-sakamoto\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\Context.js:77:12)
    at module.exports (D:\Projects\Studies\CordovaApp2\plugins\cordova-plugin-browsersync\lib\npmInstall.js:10:23)
    at runScriptViaModuleLoader (C:\Users\j-sakamoto\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:188:18)
    at runScript (C:\Users\j-sakamoto\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:164:16)
    at C:\Users\j-sakamoto\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:132:20
    at _fulfilled (C:\Users\j-sakamoto\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)

Note

I was successes installing this plugin to the cordova project, which wasn't added "android" platform.


What can I do?

Is there any workarounds?

Thanks,

Option '--livereload' not recognized (ignoring).

I get:

 Option '--livereload' not recognized (ignoring).

When adding it as a plugin, (following the 2 steps) I also tried the the project hook but its not executing after prepare either.

I would like to try the third option, but there's no examples yet. Should I run changeHost.js in my main script or somewhere else? And do I need the browserSyncServer.js perse?

It would be great if I could just point it to my already running gulp watch which runs browsersync, it just doesn't have access to the cordova.js and its plugins. If somehow I could automate the prepare process and reload the res/www directory...

ios emulator problem

Hi guys,
after run command "cordova run ios --emulator -- --live-preview"

My example app, disconect from Browser Sync. See pic;

captura de tela 2016-06-30 01 15 32

But, when connect my device, all running ok!

Any idea?

CORS options not working

cordova run -- --live-reload --enable-cors

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

how to change host

I run android with -- -- live-reload, but address at android still show localhost and thing can't work normally. How to change host ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.