Skip to content

tns livesync ios error on before-watch hook #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leocaseiro opened this issue Apr 13, 2016 · 8 comments
Closed

tns livesync ios error on before-watch hook #1676

leocaseiro opened this issue Apr 13, 2016 · 8 comments

Comments

@leocaseiro
Copy link

Hi I'm following the Building Apps with NativeScript and Angular 2 to build the groceries app. It works fine when I run tns run ios --emulator or tns livesync ios --emulator, but if I want to watch my files, doesn't work at al..
Is that any way to reload without watch?

I'm trying to run the follow command:
tns livesync ios --emulator --watch

Here's the error that happens on before-watch hook which is basically a require to the file
nativescript-dev-typescript/lib/watch.js

I've runned a trace and the log is on pastebin.
I post here the main errors:

Errors

BeforeHookName for command watch is before-watch
Executing before-watch hook from /Users/lcaseiro/Sites/native-script-groceries/hooks/before-watch/nativescript-dev-typescript.js
Executing before-watch hook at location /Users/lcaseiro/Sites/native-script-groceries/hooks/before-watch/nativescript-dev-typescript.js in-process
Found peer TypeScript 1.8.10
Hook promises to signal completion
fs.js:1315
    throw error;
    ^

Error: watch /users/lcaseiro/sites/native-script-groceries ENOENT
    at exports._errnoException (util.js:856:11)
    at FSWatcher.start (fs.js:1313:19)
    at Object.fs.watch (fs.js:1341:11)
    at addDirWatcher (/Users/lcaseiro/Sites/native-script-groceries/node_modules/typescript/lib/tsc.js:1036:39)
    at Object.addFile (/Users/lcaseiro/Sites/native-script-groceries/node_modules/typescript/lib/tsc.js:1051:21)
    at Object.watchFile (/Users/lcaseiro/Sites/native-script-groceries/node_modules/typescript/lib/tsc.js:1172:48)
    at Object.executeCommandLine (/Users/lcaseiro/Sites/native-script-groceries/node_modules/typescript/lib/tsc.js:34546:44)
    at Object.<anonymous> (/Users/lcaseiro/Sites/native-script-groceries/node_modules/typescript/lib/tsc.js:34877:4)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)

Failed during hook execution.
TypeScript compiler failed with exit code 1

tns version: 1.7.1

OSX El Capitan: 10.11.3

npm 3.8.6

Node 5.4.0

npm packages:

├── [email protected]
├── [email protected] extraneous
├── [email protected] extraneous
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   ├─┬ [email protected]
│   │ ├─┬ [email protected]
│   │ │ └── [email protected]
│   │ ├── [email protected]
│   │ ├─┬ [email protected]
│   │ │ └─┬ [email protected]
│   │ │   ├── [email protected]
│   │ │   └── [email protected]
│   │ ├─┬ [email protected]
│   │ │ └── [email protected]
│   │ └── [email protected]
│   └─┬ [email protected]
│     └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
└─┬ [email protected]
  └── [email protected]

gcc --version

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Thanks in advance!

@rosen-vladimirov
Copy link
Contributor

Hi @leocaseiro ,
This issue is addressed in our release branch and it will be included in the 2.0.0 official release.
You can find more information here and here

@leocaseiro
Copy link
Author

Thank you so much. I've tested now and worked just fine.

PS: I had to update the brew and install my xcode with: brew install xcproj

@leocaseiro
Copy link
Author

leocaseiro commented May 2, 2016

Hi @rosen-vladimirov, I'm actually having the same issue still.

However, I'm trying a new app from: tns-template-hello-world-ng

I was trying to debug and I've realised that if I comment the beforewatch/nativescript-dev-typescript.js reference it works:

beforewatch/nativescript-dev-typescript.js
// module.exports = require("nativescript-dev-typescript/lib/watch.js");

However, as you can realise, the watch won't work with any JS changes...

I'm not sure how to fix that. Could you please help me out?

node_modules/nativescript-dev-typescript/lib/watch.js

var compiler = require('./compiler');

module.exports = function ($logger, $projectData, $errors) {
    return compiler.runTypeScriptCompiler($logger, $projectData.projectDir, { watch: true });
}

@leocaseiro
Copy link
Author

UPDATE

I temporary sorted it out using gulp to watch my .ts files and then, livesync(which works while watching .js files).

In that case, my gulp task watches .ts and update all .js while livesync handles all .js files and update and sync my ios emulator...

@leocaseiro
Copy link
Author

leocaseiro commented May 3, 2016

If someone is interested in this solution, just make sure you run livesync before gulp.
Also, don't forget to comment the code in hooks/before-watch/nativescript-dev-typescript.js

npm dependencies:

npm install --save-dev yargs gulp gulp-load-plugins gulp-plumber gulp-debug gulp-if gulp-typescript gulp-sourcemaps

./gulpfile.js

'use strict';
var args = require('yargs').argv,
    gulp = require('gulp'),
    $ = require('gulp-load-plugins')({lazy: true});

var options = {
    isDebug: args.debug || false,
    isProduction: args.production || false,
    sourceFolder: ['./*.d.ts', './app/**/*.ts'],
    destinationFolder: './app'
};

gulp.task('typescript', function() {
    var tsconfigJson = require('./tsconfig.json');
    return gulp.src(options.sourceFolder)
        .pipe($.plumber())
        .pipe($.if(options.isDebug, $.debug({title: 'typescript'})))
        .pipe($.if(!options.isProduction, $.sourcemaps.init()))
        .pipe($.typescript(tsconfigJson.compilerOptions))
        .pipe($.sourcemaps.write('.'))
        .pipe(gulp.dest(options.destinationFolder));
});

gulp.task('default', ['typescript'], function() {
    gulp.watch(options.sourceFolder, ['typescript']);
});

Run with yarg debug:

gulp --debug

@leocaseiro
Copy link
Author

Hi, I'd like to reopen this issue and let people know that this problem works on a case-sensitive partition.

I formatted my MAC and I have 2 partitions now, 1 case-sensitive and another one which is not.

The case-sensitive get's the same error, where the case-insensitive runs livesync normally.

I believe in somewhere in the code or something with NodeJS perhaps. We have some case-sensitive issue.

I'll investigate and I'll up to date.

@leocaseiro
Copy link
Author

I've just noticed that the error shows Error: watch /users/lcaseiro/sites/native-script-groceries ENOENT

However, my folder structure is: /Users/lcaseiro/Sites/native-script-groceries

I'm trying to debug the addDirWatcher method which has some inheritance with Nativescript method:
CompilerHost.useCaseSensitiveFileNames()

Any help is very welcome, btw

@leocaseiro
Copy link
Author

leocaseiro commented May 31, 2016

The bug is with TypeScript, not NativeScript.

TypeScript has made some changes with case-sensitive and the solution @cmoffatt found it to Downgrade to [email protected], you can read more here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants