mean-expert-official / loopback-sdk-builder

Tool for auto-generating Software Development Kits (SDKs) for LoopBack
Other
399 stars 178 forks source link

SDKNodeModule has no exported member / angular issue #469

Open favrePoupou opened 7 years ago

favrePoupou commented 7 years ago

What type of issue are you creating?

What version of this module are you using?

Write other if any:

Please add a description for your issue:

Hi, ## Those are my client configuration: { "name": "hello-world", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^4.0.0", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.3.3", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "bootstrap": "^3.3.7", "core-js": "^2.4.1", "rxjs": "^5.4.1", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.2.5", "@angular/compiler-cli": "^4.0.0", "@angular/language-service": "^4.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "@types/socket.io-client": "^1.4.29", "codelyzer": "~3.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.0.4", "tslint": "~5.3.2", "typescript": "~2.3.3" } }

## My server configuration: { "name": "back", "version": "1.0.0", "main": "server/server.js", "engines": { "node": ">=4" }, "scripts": { "lint": "eslint .", "start": "node .", "posttest": "npm run lint && nsp check", "build:sdk": "./node_modules/.bin/lb-sdk server/server client/src/app/shared/sdk" }, "dependencies": { "@angular/http": "^4.3.3", "@mean-expert/loopback-component-realtime": "^1.0.0-rc.9.4", "@mean-expert/loopback-sdk-builder": "^2.1.0-rc.13.2", "compression": "^1.0.3", "cors": "^2.5.2", "helmet": "^1.3.0", "loopback": "^3.0.0", "loopback-boot": "^2.6.5", "loopback-component-explorer": "^4.0.0", "loopback-connector-mongodb": "^1.18.1", "serve-favicon": "^2.0.1", "socket.io-client": "^2.0.3", "strong-error-handler": "^2.0.0" }, "devDependencies": { "eslint": "^3.17.1", "eslint-config-loopback": "^8.0.0", "nsp": "^2.1.0" }, "repository": { "type": "", "url": "" }, "license": "UNLICENSED", "description": "back" }

In my app.module.ts when i try to add

import { SDKNodeModule } from './shared/sdk/index'; as described in the doc, it says that it has not exported member SDKNodeModule . When I go inside the index, there is nothong about it. In your github repo (https://github.com/mean-expert-official/loopback-sdk-builder/blob/master/lib/angular2/shared/index.ejs) Line 71 you have it, should i mostly use yours ?

Also, my shared/sdk was perfectly created with all the services and modules but i am not able to use my import of collection to access to it from my front side, maybe due to those issue that i was explaining or is that possible that it works fine only with the angular2 and not what i am using ( angular4 ) ?

On adding some parameters on my build:sdk in package.json ( "build:sdk": "./node_modules/.bin/lb-sdk server/server client/src/app/shared/sdk -d [ ng2web | ng2universal] -i [enabled | disabled]"

It displays that build_error

jonathan-casarrubias commented 7 years ago

@favrePoupou thanks for reaching out, you are having some configuration issues, let me elaborate

Whenever you see something like [ A | B ] it means that is a multiple options choice, technically means

A or B

Said that, you need to select one of the options you 'll pass to the configuration

If I correctly understand you are trying to generate an SDK that works in an AngularUniversal environment, since you are trying to import SDKNodeModule.

If what I said already makes sense to you, you will be able to figure out that the right configuration should be something like

{
 "build:sdk": "./node_modules/.bin/lb-sdk server/server client/src/app/shared/sdk -d  ng2universal -i enabled"
}

I set -i enabled since I'm assuming you want real-time features other wise, you can do

{
 "build:sdk": "./node_modules/.bin/lb-sdk server/server client/src/app/shared/sdk -d  ng2universal -i disabled"
}

I hope this helps you understand the configuration

Cheers Jon

favrePoupou commented 7 years ago

Thank you very much Jon, now i am able to import the SDKNodeModule but still have some other problem to access to my data. I don't know if I should create another ticket for that but I ask it to you because I think it may be related again to my configuration. My Mongo database is connected ,i used lb datasource for that (localhost). Then i created models on lb model. I use the loopback /explorer to see what inside and also robomongo to double check On my /common/models , I have my .js and .json file so everything is right. I try to access from component and also back end to my data but i just can do it on event listener from back as describe in this picture

build_error

The afterRemote is working fine, means when i add some value on /explorer to the Hello collections, the hook is retrieving the event in my common/models/hello.js and he is showing my console perfectly as the new value I've just added. But i'm not able to do CRUD simple operation as find or create. You can see it on the picture below the hook, i put it inside a function called dede() and it is exactly executed but i have some error like this: build_error

The same thing from my front side, I am not able to make some crud operation:

build_error

This is my front end result:

build_error