Tns run android --bundle won't work


#1

i configured my webpack the same as it is in the documentation , then when i run tns run android i get this message

Executing before-liveSync hook from C:\Users\sss-g\Documents\HelloWorld\hooks\before-liveSync\nativescript-angular-sync.js                         
up to date in 10.439s                                                                                                                              
Executing before-prepare hook from C:\Users\sss-g\Documents\HelloWorld\hooks\before-prepare\nativescript-dev-typescript.js                         
Preparing project...                                                                                                                               
Executing before-prepareJSApp hook from C:\Users\sss-g\Documents\HelloWorld\hooks\before-prepareJSApp\nativescript-dev-webpack.js                  
Running webpack for Android...                                                                                                                     
module.js:538                                                                                                                                      
    throw err;                                                                                                                                     
    ^                                                                                                                                              
                                                                                                                                                   
Error: Cannot find module 'C:\Users\sss-g\Documents\HelloWorld\node_modules\@ngtools\webpack'                                                      
    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 Object.<anonymous> (C:\Users\sss-g\Documents\HelloWorld\node_modules\nativescript-dev-webpack\plugins\NativeScriptAngularCompilerPlugin.js:1
0:27)                                                                                                                                              
    at Module._compile (module.js:635:30)                                                                                                          
    at Object.Module._extensions..js (module.js:646:10)                                                                                            
    at Module.load (module.js:554:32)                                                                                                              
    at tryModuleLoad (module.js:497:12)                                                                                                            
    at Function.Module._load (module.js:489:3)                                                                                                     
Unable to apply changes on device: PSE7N17407001621. Error is: Executing webpack failed with exit code 1..                                         
Executing after-watch hook from C:\Users\sss-g\Documents\HelloWorld\hooks\after-watch\nativescript-dev-typescript.js

#2

Are you sure you installed all dependencies after updating your package.json?


#3

yes i’m sure, even when when i try running without webpack using tns run android
it display a warning

npm WARN schema-utils@0.4.3 requires a peer of webpack@^2.0.0 || ^3.0.0 but none was installed.
but it runs successfully

here my package.json

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.FirstApp",
    "tns-android": {
      "version": "3.4.0"
    }
  },
  "dependencies": {
    "nativescript-theme-core": "~1.0.4",
    "tns-core-modules": "~3.4.0"
  },
  "devDependencies": {
    "awesome-typescript-loader": "~3.1.3",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.0.1",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.0",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.6.0",
    "nativescript-dev-webpack": "^0.9.0",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.1.0",
    "typescript": "~2.4.2",
    "webpack": "~3.8.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1"
  }
}

#4

Is it a Typescript project (non Angular)?


#5

i’ve tried both same probleme :confused:


#6

have you read this blog for latest changes for webpack


#7

Hope you are using the latest version of CLI. On my end I was not able to reproduce the issue, it works fine. May be if you can create a sample project where we can reproduce the issue, we may able to help.


#8

i’ve solved it, i just needed to install the dependencies globally with -g so i can use from any directory, and thank very much for your help :slight_smile: