NS Angular + Webpack + Onesignal plugin


Hi, I’m currently working on a project which uses the OneSignal NS plugin for push notifications.

It works fine, and it used to build / run correctly with Webpack enabled until I started using the OneSignal plugin.

I’m not exactly shure on how to configure my project to get a webpack build.

This is the plugin I’m referring to: https://github.com/roblav96/nativescript-onesignal

It asks to add this line on the source code to use it (and this is which I’m currently doing), so I did, for example, in a file named main.module.ts:

let TnsOneSignal = require(“nativescript-onesignal”).TnsOneSignal;

I’ve found I should register the modules I’m using with Webpack, and I’ve tried a few things, but it didn’t work.

Something like this:

global.registerModule(“nativescript-onesignal”, ()=> require(’…/node_modules/nativescript-onesignal’));

The error(s) I get are like this:

ERROR in ./modules/main/main.module.ts
Module not found: Error: Can’t resolve ‘nativescript-onesignal’ in ‘EDITED-APP-PATH/my-app/app
@ ./modules/main/main.module.ts 8:19-52
@ ./app.module.ngfactory.ts
@ ./main.aot.ts

I’ve found some topics on this forum, but I couldn’t get any working solution from them.

Any help or hints will be appreciated.

This is my current package.json:

  "description": "App",
  "license": "LicenseRef-LICENSE",
  "readme": "README",
  "nativescript": {
    "id": "com.app.name"
  "dependencies": {
    "@angular/animations": "~4.1.0",
    "@angular/common": "~4.1.0",
    "@angular/compiler": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/router": "~4.1.0",
    "nativescript-angular": "~3.0.0",
    "nativescript-iqkeyboardmanager": "^1.0.1",
    "nativescript-localize": "^2.0.1",
    "nativescript-onesignal": "^1.0.6",
    "nativescript-telerik-ui": "^2.0.1",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "^3.0.1",
    "zone.js": "~0.8.2"
  "devDependencies": {
    "@angular/compiler-cli": "~4.1.0",
    "@ngtools/webpack": "1.3.1",
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.1",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "~2.1.0",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-custom-entitlements": "^0.2.0",
    "nativescript-dev-sass": "^1.1.1",
    "nativescript-dev-typescript": "~0.4.0",
    "nativescript-dev-webpack": "^0.6.0",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.0.2",
    "tns-platform-declarations": "^3.0.0-rc.2",
    "typescript": "~2.2.1",
    "webpack": "~2.5.1",
    "webpack-sources": "~0.2.3"
  "scripts": {
    "ns-bundle": "ns-bundle",
    "start-android-bundle": "npm run ns-bundle --android --start-app",
    "start-ios-bundle": "npm run ns-bundle --ios --start-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app"

Issue with webpack and plugins

If someone is interested in this or a similar problem, Nick Iliev gave me the right answer here:


Just change the name from onesignal.js to onesignal on package.json



I have just created this topic: Issue with webpack and plugins
I see it woked for you, is it steel the case? do you had some configuration? I have try with the demo code (juste add var TnsOneSignal = require(‘nativescript-onesignal’).TnsOneSignal), and got on error…