Hello,
So a few days i started this app and --watch was working just fine until today.
This is what i call: tns run android --emulator --device=ANDROID --watch
but when i change code, nothing happens, my changes are not present.
When i run tns doctor, it shows that everything is up to date except ios emulator( witch i am not using at this time ).
Nobody ? Ideas ?
Just tried to reinstall the app( from git ) and re-created the avd. still --watch not working.
Hello @IvRRimum
You are using _run_ instead of _livesync_ The command to execute your app and watch for changes is the following
tns livesync android --watch
If you want to pass a specific device you can do it with the --device key and an ID of the device
For example
woth
tns device
โ # โ Device Name โ Platform โ Device Identifier โ Type โ Status โ
โ 1 โ vbox86p โ Android โ 192.168.206.102:5555 โ Emulator โ Connected โ
โ 2 โ vbox86p โ Android โ 192.168.206.101:5555 โ Emulator โ Connected โ
Now you pass as id 1 to run your app on this specific device
For example:
tns livesync android --watch --device 1
@NickIliev THANKS! However, everytime it syncs the changes, after it reverts all my code changes..
@NickIliev Update: It only undoes my code changes, when i stop the tns livesync.. and start it again. How does one fix that ?
@IvRRimum are you trying to sync changes made to XML or CSS files - if so I suspect you have reproduced the issue discussed at https://github.com/NativeScript/nativescript-cli/issues/1907
This bug with livesync not syncing XML and CSS files is now fixed and the fix will be released with our next release.
@NickIliev Okey, what i am suposed to do now ? I need this working today or i am getting an ass kicking from my boos ;[
@IvRRimum you can install our next nativescript-cli where the bug-fix is applied.
Here are the steps to achieve that (notice that this will install tns v.2.2.0 which is not official release yet)
mkdir latest-cli
cd latest-cli
git clone https://github.com/NativeScript/nativescript-cli
cd nativescript-cli
git submodule update --init
npm install
grunt
Now let's assume your folder _latest-cli_ is located in your D: partition
In order to run your project with the latest cli you should give your full path to the tns executable
For example:
D:\latest-cli\nativescript-cli\bin\tns livesync --watch android
Now your project will be livesynced with tns v2.2.0 where the fix for livesync is implemented.
The how-to build with local cli article can be found here : https://github.com/NativeScript/nativescript-cli#how-to-build
@NickIliev Thanks, will try that. P.S I am using linux
karlis@karlis-SATELLITE-L750 ~/Projects/my-instagram/latest-cli/nativescript-cli $ git submodule update --init
Cloning into 'lib/common'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:telerik/mobile-cli-lib.git' into submodule path 'lib/common' failed
Hey @IvRRimum
This error is caused more likely because you do not have SSH key set to your github.
Check this discussion where the solution is described : https://github.com/NativeScript/nativescript-cli/issues/1916#issuecomment-232360061
Basically, you need to set an SSH key in https://github.com/settings/keys
Here is a github how-to add new SSH key : https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
EDIT: here is the link for generating SSH in Linux : https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux
but this step is optional. Also why do i need grunt ? when i run without grunt i get:
karlis@karlis-SATELLITE-L750 ~/Projects/my-instagram/latest-cli/nativescript-cli $ ~/Projects/my-instagram/latest-cli/nativescript-cli/bin/tns livesync android --watch --device=emulator-5554
module.js:440
throw err;
^
Error: Cannot find module '../lib/nativescript-cli.js'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
Also, grunt fails
Note: You may wish to enable the suppressImplicitAnyIndexErrors grunt-ts option to allow dynamic property access by index. This will suppress TypeScript error TS7017.
1995 non-emit-preventing type warnings
Error: tsc return code: 2
Warning: Task "ts:devlib" failed. Use --force to continue.
Great, this broke all of my previous tns installations.
Now when i run tns:
karlis@karlis-SATELLITE-L750 ~/Projects/my-instagram/latest-cli/nativescript-cli $ tns
module.js:440
throw err;
^
Error: Cannot find module './common/verify-node-version'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
Grunt is automation tool which runs a set of tasks which otherwise should be run manually by the user.
Without running grunt command your CLI won't be installed properly as those tasks won't be executed.
As for your grunt error - this error log is discussed here https://github.com/NativeScript/nativescript-cli/issues/250 you can check if the solution is working out for your environment.
If you want to revert to tns 2.1.0 run
npm uninstall -g nativescript
npm install -g nativescript
I followed your instructions( including grunt ). Now when i run ~/Projects/my-instagram/latest-cli/nativescript-cli/bin/tns livesync android --watch --device=emulator-5554
My changes is still reverted... Is nativescript-cli still in beta or something ?
@IvRRimum
Can you give us more detailed information about your issue:
1.) is it CSS, XML or js/ts file that you are changing?
2.) What do you mean by reverting!? There is no logic in the CLI to revert changes made by the user in their files. Can you explain step by step what is happening in your project? As far as I understand
Is that what's happening?
1) Yes, i have an nativescript( with angular2 ), i change .js files( and maybe and .html file sometimes ).
2) For example, when the command tns livesync... is running i change something - it ussualy syncs. But when i stop the command and run command again. All my changes are lost( witch i made while i was in sync ).
Like everytime i run the livesync command, it takes the old changes. It's probably that i am being moronic, not doing something correctly ?
@IvRRimum
We will investigate further the issue you are having.(we were able to reproduce it locally on one machine) and I will follow up when we have a solution/fix.
In our case the changes made to the code are NOT lost - they are not applied but still present in the places they are made.
As a temp workaround, you can rebuild your app after stopping livesync.
To do that remove the platform folder and then execute your new livesync/run command.
This will force your app to be built with your last changes.
Can you also give us more details about the environment you are working on
(like OS, Node.js version, npm version)
P.S My current monkey-pached workflow: I run livesync, code my stuff, but if i need to restart livesync command i commit eveything. Then i run livesync, wait till it reverts all my changes, then git reset --hard after it syncs i can work again.
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=17.3
DISTRIB_CODENAME=rosa
DISTRIB_DESCRIPTION="Linux Mint 17.3 Rosa"
NAME="Ubuntu"
VERSION="14.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.4 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
cat: /etc/upstream-release: Is a directory
node - v6.0.0
npm - 3.10.5
Thanks, ping me, if you have some news.
Thanks for help! I still can work further and that's what matter right now.
P.S I was wrong, it is still not working... ;//
As i see it now, it looks like its some kind of cache, do you have cache somewhere in there ? How can i clear it ?
Hey @IvRRimum
Try the following flow:
at this moment your changes should be present in your IDE (VSCode or what you are using). There is no code in our CLI that can revert changes made in your files. If at this point you do not have your changes saved in your files then you should probably check your local permission settings for writing/reading files.
rm -rf platforms )At this point, all changes should be applied and your attached device/emulator should present them.
Please do not hesitate to report back on how your environment is responding to this workflow.
@IvRRimum I noticed you said you're using Angular2 but made changes to .js files. I don't know what .js files you're talking about for sure. Angular2 usually uses TypeScript (.ts) files and those compile/transpile to .js. If you make a change to one of those .js files, then when the transpiler runs on the .ts file, you'll lose those changes you made in your .js. I'm assuming you know this already, but just in case you don't, I thought I would mention it.
There has been a bug reported (not sure the number or if its open anymore) that sometimes the NativeScript "compile" process doesn't pick up changes to certain files, usually .xml/.html files and it ends up putting old versions in the .apk (android). I've seen this myself and did eventually resolve the issue though I never figured out what I did that resolved it (I tried a lot of different things). It could be this is the issue you're having and I think it's the issue that @NickIliev is eluding to in his replies.
@burkeholland Didn't know that... Will try, right now the app just woun't. Will try to fix.
Yes, that was it. But ofcourse i have 1 more last problem...
Now when i start application up, it shows error:
Failed to find module 'nativescript-angular/application', relative to 'app/tns_modules'
I tryed to add code references.d.ts file: ///
No luck.. Any ideas ? Last problem.
@IvRRimum glad to hear that you have resolved your main issue! Kudos to @harlankoehn !
As for your current problem - You should reset your platforms folder
tns platform remove android
tns platform add android
or
rm -rf platforms
tns platform add android
and then rebuild your app to install all dependencies including nativescript-angular/application'
tns run android
The situation is explained here
Did what you sayd, still the same problem ;///
Also the link is dead ;/
Problem is still there.. ://
@IvRRimum can you paste the content of your package.json
You can try to remove your node_modules (as the nativescript-angular/application is not present in your project) and then rebuild your project
rm -rf node_modules
rm -rf platforms
npm install
tns platform add android
tns run android
. If this does not solve your problem you can send us your sample project (Github link or here with archive) to test it locally (again no need to upload platforms and node_modules folders)
Hey @IvRRimum I have noticed you have posted a question about working with nativescript-firebase plugin - are your problems discussed here resolved?
Hey, yeah. I just followed the tutorial video. I still have 1 error in console, but it doesn't effect the app's functionality. So thats wierd. Thanks!
I think a tsc watch compilation is necessary to me.