question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AOT & Angular-CLI throw errors using the base example, new one here

See original GitHub issue

We had a ton of issues related to missing parameters, bad constructors, etc.

First was the @injectable which I detailed on #76.

The AOT example shows how to use rollUp but Angular pushes people to use the CLI.

To use the CLI, you must include the scripts for cloudinary as a global. Inside .angular-cli.json

scripts:["../node_modules/cloudinary-core/cloudinary-core-shrinkwrap.js"]

This will insure that cloudinary is loaded into the global namespace. We used the shrinkwrap version because the lib needs lodash and the shrinkwrap version has the specific lodash bundled together.

Then in your app.module

// cloudinary.. order may be important with AOT
import { Cloudinary } from 'cloudinary-core/cloudinary-core-shrinkwrap';
import { CloudinaryModule, CloudinaryConfiguration } from '@cloudinary-angular';

const cloudConfig = {
  cloud_name: 'your-cloud'
};

const cloudinaryLib = {
  Cloudinary: Cloudinary
};

@NgModule({
  imports: [
          BrowserModule,
          BrowserAnimationsModule,
          CommonModule,
          FormsModule,
          CloudinaryModule.forRoot(cloudinaryLib, cloudConfig)
    ///rest of your code

This cleared all the errors and got everything to compile… Hope it helps!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mrkhangtrancommented, May 10, 2018

For anyone still looking for the solutions, it is here (Angular 5 CLI) https://github.com/cloudinary/cloudinary_angular/tree/master/samples/angular-cli-sample

1reaction
RomainMarecatcommented, Mar 17, 2017

Hello ! I had the same issue with

@angular/cli: 1.0.0-rc.2 node: 7.7.2 os: linux x64 @angular/common: 2.4.9 @angular/compiler: 2.4.9 @angular/core: 2.4.9 @angular/forms: 2.4.9 @angular/http: 2.4.9 @angular/platform-browser: 2.4.9 @angular/platform-browser-dynamic: 2.4.9 @angular/router: 3.4.9 @angular/cli: 1.0.0-rc.2 @angular/compiler-cli: 2.4.9 @cloudinary/angular: ^2.1.1 cloudinary-core: ^2.2.0

I try all posibilities in my module : Today the best solution is the last with ng serve works ng serve -aot doesn’t work. EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'CloudinaryJQuery' of null ng build -prod doesn’t work EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'CloudinaryJQuery' of null ng build -aot doesn’t work EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'CloudinaryJQuery' of null

UPDATE 1

import { Cloudinary } from 'cloudinary-core';
import { CloudinaryModule, CloudinaryConfiguration } from '@cloudinary/angular';
import { CloudinaryConfig } from './../../shared/cloudinary.config';

@NgModule({
  imports: [
    BrowserModule,
    CommonModule,
    FileUploadModule,
    CloudinaryModule.forRoot(Cloudinary, CloudinaryConfig),
  ]
})
export class UserModule {}

UPDATE 2

import * as Cloudinary from 'cloudinary-core';
import { CloudinaryModule, CloudinaryConfiguration } from '@cloudinary/angular';
import { CloudinaryConfig } from './../../shared/cloudinary.config';

const cloudinaryLib = {
  Cloudinary: Cloudinary
};

@NgModule({
  imports: [
    BrowserModule,
    CommonModule,
    FileUploadModule,
    CloudinaryModule.forRoot(cloudinaryLib, CloudinaryConfig),
  ]
})
export class UserModule {}

UPDATE 3

import Cloudinary from shrinkwrap doesn’t works too : import { Cloudinary } from 'cloudinary-core/cloudinary-core-shrinkwrap';

ERROR in ~/src/app/admin/user/user.module.ts (14,28): Cannot find module 'cloudinary-core/cloudinary-core-shrinkwrap'.)

UPDATE 4

import * as Cloudinary from 'cloudinary-core';
import { CloudinaryModule, CloudinaryConfiguration, provideCloudinary } from '@cloudinary/angular';

const cloudinaryLib = {
  Cloudinary: Cloudinary
};

@NgModule({
  imports: [
    BrowserModule,
    CommonModule,
    FileUploadModule,
    CloudinaryModule.forRoot(cloudinaryLib, CloudinaryConfig),
  ]
})

export class UserModule {}

TypeError: cloudinaryJsLib.Cloudinary is not a constructor

UPDATE 5

// user.module.ts
import * as Cloudinary from 'cloudinary-core';
import { CloudinaryModule, CloudinaryConfiguration } from '@cloudinary/angular';
import { CloudinaryConfig } from './../../shared/cloudinary.config';

@NgModule({
  imports: [
    BrowserModule,
    CommonModule,
    FileUploadModule,
    CloudinaryModule.forRoot(Cloudinary, CloudinaryConfig),
  ]
})
export class UserModule {}

In .angular-cli :

"scripts": [
	"../node_modules/jquery/dist/jquery.js",
	"../node_modules/cloudinary-core/cloudinary-core-shrinkwrap.js",
],

I try to add in my packages.json typings like that with eitanp461’s typings (https://github.com/cloudinary/cloudinary_js/pull/122/commits/714d27d15b7880d21f094bdc1f674d025e7389a7), but it doesn’t work too :

{ 
  "dependencies": {
    ...
  },
  "typings": "src/cloudinary-core.d.ts"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ahead-of-time (AOT) compilation
AOT compiles HTML templates and components into JavaScript files long before they are served to the client. With no templates to read and...
Read more >
Angular: Writing AoT-friendly applications | by David
The article talks through this topic by an example app. ... For an overview, here are the Angular CLI commands for both development...
Read more >
cannot determine the module for component angular 5
Check Case Sensitivity import { MyComponent } from "./User/my-component";. In my case, the problem was that the folder user was created with ......
Read more >
Improved Error Logging by the Angular AOT Compiler
For the years, one of the biggest pain in Angular was to debug, because of the error message, there was no clear stack...
Read more >
Using the Ahead-of-Time (AOT) Compiler
The Angular AOT compiler extracts the metadata to interpret the Angular application in equivalent JavaScript code. It recognizes the code based ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found