Skip to content

Watch 'node_modules' directory when running tns run #3092

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
otaran opened this issue Aug 28, 2017 · 6 comments
Closed

Watch 'node_modules' directory when running tns run #3092

otaran opened this issue Aug 28, 2017 · 6 comments

Comments

@otaran
Copy link

otaran commented Aug 28, 2017

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes, there is an issue #2303 but it was closed without resolution 5 months ago.

Tell us about the problem

I have to restart my app each time I modify any node module that my app depends on, because it doesn't get synced to my app while tns run is still running.

Which platform(s) does your issue occur on?

Both Android and iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.1.3
  • Cross-platform modules: 3.1.1
  • Runtime(s): 3.1.0
  • Plugin(s): N/A

Please tell us how to recreate the issue in as much detail as possible.

See attached project.

my-lib-a is a module which is specified as a dependency in package.json and installed using npm install. When you run the app using tns run and modify file my-app/node_modules/my-lib-a/index.js, your changes WILL NOT get synced to the running app. Because of that, it is inconvenient to develop library modules due to the fact that you have to restart your app each time you modify your library.

my-lib-b is a module which is symlinked under my-app/app/tns_modules. When you run the app using tns run and modify file my-lib-b/index.js, your changes WILL get synced to the running app. This is the workaround I am using in my apps, though I am concerned that it will get broken in the future nativescript-cli releases because it is an undocumented implementation-specific "feature".

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

See attached project.

@otaran
Copy link
Author

otaran commented Aug 28, 2017

Although I am OK with the app/tns_modules/my-lib-b workaround, I do realise it is undocumented and therefore can get broken in any future release of Nativescript CLI. I was wondering if there is any "official workaround" for Nativescript CLI not supporting watching node_modules directory?

@rosen-vladimirov
Copy link
Contributor

Hey @otaran ,
Currently you can pass --syncAllFiles to tns run command, which will start watching both package.json and node_modules. This is the official way to sync changes in node_modules.
However, keep in mind this will watch all files and folders in your node_modules, so you may hit maximum number of file system watchers on your machine (it happens on some linux/macOS machines where the default value of the watcher is low).
We've been discussing an idea to include a configuration file at the root of the project, where you'll be able to set which files/dirs you want to be watched? What do you think about this?

@otaran
Copy link
Author

otaran commented Aug 30, 2017

Hi @rosen-vladimirov, thanks for mentioning --syncAllFiles, I didn't know about this option and it's exactly what I was looking for!

Having a config file (or a CLI option) for specifying directories being watched will definitely be welcome, I could use it to watch only node_modules/my-lib-a instead of the whole node_modules, which I guess will improve the performance and robustness of tns run.

@otaran otaran closed this as completed Aug 30, 2017
@rui-cruz
Copy link

Hi, I need to just watch symlink modules. I'm on a mono-repo where some libs are on root and added to package.json by "@AwesomeLib": "file:../../libs/awesomelib", what are the chances to make only this watchable?

Thank you

@JonnyBGod
Copy link

I am having the same problem as @rui-cruz any plans to support whitelisting node_modules folders?

@DimitarTachev
Copy link
Contributor

DimitarTachev commented Apr 1, 2019

Hi @rui-cruz @JonnyBGod,

We are using the same workflow in our internal plugins (e.g. take a look at the Image Picker plugin structure).

Ensure that you are passing the --syncAllFiles flag to the tns run commands in your demo and you have the linked plugin properly configured in the tsconfig (take a look at the include and exclude sections of the Image Picker demo).

If your plugin is created from the official plugin seed, these configurations will be applied out of the box.

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

5 participants