Nativescript + ng + webpack hello world project build failed


#1

C:\Users\selvam>npm i -g nativescript
npm WARN deprecated node-uuid@1.4.7: Use uuid module instead
npm WARN deprecated lodash-node@2.4.1: This package is discontinued. Use lodash@^4.0.0.
npm WARN deprecated node-uuid@1.3.3: Use uuid module instead
C:\Users\selvam\AppData\Roaming\npm\tns -> C:\Users\selvam\AppData\Roaming\npm\node_modules\nativescript\bin\tns
C:\Users\selvam\AppData\Roaming\npm\nativescript -> C:\Users\selvam\AppData\Roaming\npm\node_modules\nativescript\bin\tns

fsevents@1.1.2 install C:\Users\selvam\AppData\Roaming\npm\node_modules\nativescript\node_modules\fsevents
node install

nativescript@3.1.2 postinstall C:\Users\selvam\AppData\Roaming\npm\node_modules\nativescript
node postinstall.js

Support for Node.js 8.1.4 is not verified. This CLI might not install or run properly.

NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.

Your components are up-to-date.

Autocompletion is already enabled

Installation successful. You are good to go. Connect with us on http://twitter.com/NativeScript.

  • nativescript@3.1.2
    added 433 packages in 105.115s

C:\Users\selvam>npm i -g webpack
C:\Users\selvam\AppData\Roaming\npm\webpack -> C:\Users\selvam\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js

fsevents@1.1.2 install C:\Users\selvam\AppData\Roaming\npm\node_modules\webpack\node_modules\fsevents
node install

uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\selvam\AppData\Roaming\npm\node_modules\webpack\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

  • webpack@3.2.0
    added 341 packages in 46.532s

C:\Users\selvam>tns create ngwebpack2 --ng

Support for Node.js 8.1.4 is not verified. This CLI might not install or run properly.

Installing tns-template-hello-world-ng

  • tns-template-hello-world-ng@3.1.1
    added 18 packages in 15.532s

nativescript-dev-typescript@0.5.0 postinstall C:\Users\selvam\ngwebpack2\node_modules\nativescript-dev-typescript
node postinstall.js

Adding ‘es6’ lib to tsconfig.json…
Adding ‘dom’ lib to tsconfig.json…
Adding ‘es2015.iterable’ lib to tsconfig.json…
Adding tns-core-modules path mappings lib to tsconfig.json…
Project already targets TypeScript ~2.2.1
added 15 packages in 8.594s
Project ngwebpack2 was successfully created.

C:\Users\selvam>ng ngwebpack2
’ng’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\selvam>cd ngwebpack2

C:\Users\selvam\ngwebpack2>npm install --save-dev nativescript-dev-webpack

nativescript-dev-webpack@0.7.3 postinstall C:\Users\selvam\ngwebpack2\node_modules\nativescript-dev-webpack
node postinstall.js

Creating file: C:\Users\selvam\ngwebpack2\webpack.config.js
Creating file: C:\Users\selvam\ngwebpack2\tsconfig.aot.json
Creating file: C:\Users\selvam\ngwebpack2\app\vendor-platform.android.ts
Creating file: C:\Users\selvam\ngwebpack2\app\vendor-platform.ios.ts
Creating file: C:\Users\selvam\ngwebpack2\app\vendor.ts
Registering script: ns-bundle
Registering script: start-android-bundle
Registering script: start-ios-bundle
Registering script: build-android-bundle
Registering script: build-ios-bundle
Registering script: publish-ios-bundle
Registering script: generate-android-snapshot
Adding dev dependency: webpack@~3.2.0
Adding dev dependency: webpack-bundle-analyzer@^2.8.2
Adding dev dependency: webpack-sources@~1.0.1
Adding dev dependency: copy-webpack-plugin@~4.0.1
Adding dev dependency: raw-loader@~0.5.1
Adding dev dependency: nativescript-css-loader@~0.26.0
Adding dev dependency: resolve-url-loader@~2.1.0
Adding dev dependency: extract-text-webpack-plugin@~3.0.0
Adding dev dependency: @angular/compiler-cli@~4.1.0
Dev dependency: typescript already added. Leaving version: ~2.2.1
Adding dev dependency: @ngtools/webpack@~1.5.0

NativeScript Webpack plugin was successfully added.
You can now bundle your project with the following npm scripts:
- “npm run build-android-bundle” to build for android.
- “npm run build-ios-bundle” to build for ios.
- “npm run start-android-bundle” to run on android.
- “npm run start-ios-bundle” to run on ios.
You can also pass the “–uglify” flag to use UglifyJS for minification.
For more information check out https://docs.nativescript.org/tooling/bundling-with-webpack#bundling.

Some dependencies have already been added. If you want to force update them, please run “node_modules/.bin/update-ns-webpack”.

A few new dependencies were added. Run “npm install” before building your project.

  • nativescript-dev-webpack@0.7.3
    added 3 packages in 3.89s

C:\Users\selvam\ngwebpack2>npm i
up to date in 12.656s

C:\Users\selvam\ngwebpack2>npm run start-android-bundle

@ start-android-bundle C:\Users\selvam\ngwebpack2
npm run ns-bundle --android --run-app

@ ns-bundle C:\Users\selvam\ngwebpack2
ns-bundle

Running tns prepare…

Support for Node.js 8.1.4 is not verified. This CLI might not install or run properly.

Copying template files…
/ Installing tns-androidInstalling tns-android
/ Installing tns-android[ …] - extract:tns-android: verb lock using added 1 package in 2.274s
Project successfully created.
Executing before-prepare hook from C:\Users\selvam\ngwebpack2\hooks\before-prepare\nativescript-dev-typescript.js
Preparing project…
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Configuring > 0/3 projects > root project
:config phase: createDefaultIncludeFiles
Configuring > 0/3 projects > root project
:config phase: addAarDependencies
+adding dependency: C:\Users\selvam\ngwebpack2\platforms\android\libs\aar\widgets-release.aar
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
Incremental java compilation is an incubating feature.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_d3pkhgwqpirjqau9zild6b7qq.run(C:\Users\selvam\ngwebpack2\platforms\android\build-tools\android-static-binding-generator\build.gradle:126)
:asbg:clean UP-TO-DATE
:deleteMetadata
:deleteFlavors
:deleteConfigurations UP-TO-DATE
:deleteGeneratedBindings UP-TO-DATE
:clean

BUILD SUCCESSFUL

Total time: 58.079 secs
Successfully prepared plugin nativescript-angular for android.
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin nativescript-intl for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (android)

Support for Node.js 8.1.4 is not verified. This CLI might not install or run properly.

Running webpack for android…
module.js:487
throw err;
^

Error: Cannot find module 'webpack’
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\selvam\ngwebpack2\webpack.config.js:3:17)
at Module._compile (module.js:569:30)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
child process exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ ns-bundle: ns-bundle
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ ns-bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\selvam\AppData\Roaming\npm-cache_logs\2017-07-14T03_18_57_017Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start-android-bundle: npm run ns-bundle --android --run-app
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start-android-bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\selvam\AppData\Roaming\npm-cache_logs\2017-07-14T03_18_57_173Z-debug.log

C:\Users\selvam\ngwebpack2>


#2

Try using lower version of Node.js as from the log you posted it seems that you are using Node 5.1.4 and you can see a recurrent warning

Support for Node.js 8.1.4 is not verified. This CLI might not install or run properly.


#3

it is working, thanks.