Skip to content

After update HMR not working on Angular - Error: "Module not found" #6544

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
andresg747 opened this issue Nov 11, 2018 · 5 comments
Closed

Comments

@andresg747
Copy link

andresg747 commented Nov 11, 2018

Environment

  • CLI: 5.0.0
  • Cross-platform modules: 5.0.2
  • Android Runtime: 5.0.0
  • iOS Runtime: 5.0.0
  • Plugin(s):
    "nativescript-localstorage": "^1.1.5",
    "nativescript-pulltorefresh": "^2.1.1",
    "nativescript-snackbar": "^3.1.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-chart": "^3.6.1",
    "nativescript-ui-listview": "^3.5.11",
    "nativescript-ui-sidedrawer": "~4.1.0",

Describe the bug
When running tns run [android | ios] --hmr I get the following errors: Full Log.
The app (obviously), crashes on the device.
When running the same command without the HMR flag, the app runs perfectly.

To Reproduce
tns run [android | ios] --hmr

Expected behavior
Working Hot Module Replacement

I've added the script on main.ts and have "nativescript-dev-webpack": "0.17.0" installed.

Any help would be very appreciated. Thanks in advance.

@Fatme
Copy link
Contributor

Fatme commented Nov 11, 2018

@andresg747,

Maybe your webpack.config,js or your webpack's dependencies are not updated. Try to execute the following:

./node_modules/.bin/update-ns-webpack --deps
./node_modules/.bin/update-ns-webpack --configs

@andresg747
Copy link
Author

Hi, @Fatme.
I've run both commands, then run the tns run android --hmr and now i get the following:

Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398
To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in this wiki: https://github.com/NativeScript/nativescript-angular/wiki/HMR
Executing before-liveSync hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-watchPatterns hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-watchPatterns/nativescript-dev-sass.js
Executing before-watchPatterns hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-watchPatterns/nativescript-dev-typescript.js
Executing before-watchPatterns hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-watchPatterns/nativescript-dev-webpack.js
Executing before-watch hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-watch/nativescript-dev-sass.js
Hook skipped because bundling is in progress.
Executing before-watch hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-watch/nativescript-dev-typescript.js
Hook skipped because bundling is in progress.
Executing before-watch hook from /Users/agarciag/Documents/nativescript/LiveData/hooks/before-watch/nativescript-dev-webpack.js
Running webpack for Android...
module.js:549
    throw err;
    ^

Error: Cannot find module '/Users/agarciag/Documents/nativescript/LiveData/node_modules/webpack/bin/webpack.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
Executing webpack failed with exit code 1.
Cannot read property 'kill' of undefined

Still, running without HMR flag, is working correctly.

@Fatme
Copy link
Contributor

Fatme commented Nov 11, 2018

@andresg747,

It seems it is still not updated correctly.

  1. rm -rf node_modules
  2. rm -rf hooks
  3. rm -rf platforms
  4. rm -rf webpack.config.js
  5. Ensure nativescript-dev-webpack: 0.17.0 is written in package.json
  6. Ensure nativescipt-angular: 6.2.0 is written in your package.json
  7. Ensure the following code snippet https://github.com/NativeScript/nativescript-angular/wiki/HMR#enable-hmr-in-nativescript-angular-project is added
  8. npm i
  9. tns run ios | android --hmr

NOTE: --hmr mode does not work for projects containing lazy loading - NativeScript/nativescript-angular#1564.

@tsonevn
Copy link
Contributor

tsonevn commented Nov 12, 2018

This issue was moved to NativeScript/nativescript-angular#1603

@tsonevn tsonevn closed this as completed Nov 12, 2018
@lock
Copy link

lock bot commented Nov 12, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants