Skip to content

"Uncaught Error: define cannot be used indirect" when using jsonix in angular 6 #202

Closed

Description

@HugoJBello

I am trying to import jsonix from an angular 6 project. It installs ok, but when I run ng serve I get the following error through the console

Uncaught Error: define cannot be used indirect
    at push../node_modules/webpack/buildin/amd-define.js.module.exports (amd-define.js:2)
    at Object.<anonymous> (jsonix.js:6103)
    at Object../node_modules/jsonix/jsonix.js (jsonix.js:6129)
    at __webpack_require__ (bootstrap:76)
    at Object../src/app/app.component.ts (main.js:94)
    at __webpack_require__ (bootstrap:76)
    at Object../src/app/app.module.ts (app.component.ts:9)
    at __webpack_require__ (bootstrap:76)
    at Object../src/main.ts (main.ts:1)
    at __webpack_require__ (bootstrap:76)

This is my package.json:

{
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.1.7",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "jsonix": "^2.4.1",
    "ngx-string-to-css-color": "0.0.12",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.6",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.7",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}

Activity

  1. highsource commented on Sep 22, 2018

    @highsource
    Owner

    I think this is duplicate of #171.

  2. self-assigned this
    on Sep 22, 2018
  3. highsource commented on Sep 22, 2018

    @highsource
    Owner

    Basically, Jsonix dist is just one JS file. It has a more-or-less UMD-style wrapper to allow it run in Node.js, with RequireJS and AMD.

    Ok, This does not work with Webpack because it probably has its own magic.

    The quiestion is ultimately, what should Jsonix-all.js look like so that it works with Webpack? Here, I need your input. I have no experience with Webpack so I'll need help with this.

  4. HugoJBello commented on Sep 22, 2018

    @HugoJBello
    Author

    Thanks for your answer. I realise now that the question was duplicated indeed. I do not know right now how to fix the compatibility with webpack but I'll give it a thought.
    I just want to point out that three months ago I had no problems using jsonix with angular 6 but since one of the last updates the problem appeared.
    I'll research the subject a little.
    Keep up the good work.

  5. highsource commented on Sep 22, 2018

    @highsource
    Owner

    Hm, that's strange.

    If you figure out what the UMD wrapper should look like to work with Webpack, I'll be happy to fix this.

  6. jether2011 commented on Sep 22, 2018

    @jether2011
  7. added this to the 2.4.2 milestone on Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions