Loopback: slc loopback:relation throws error

Created on 4 May 2016  Β·  94Comments  Β·  Source: strongloop/loopback

When I run the loopback relation command I get an error after I enter the property name for the relation.

The error:

/usr/local/lib/node_modules/strongloop/node_modules/rx/dist/rx.js:77
    throw e;
    ^
true

Here is a log of my terminal so you can see all the options I selected:

$ slc loopback:relation
(node:31096) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
? Select the model to create the relationship from: Sport
? Relation type: has one
? Choose a model to create a relationship with: PerformanceEvaluation
? Enter the property name for the relation: (performanceEvaluations)


/usr/local/lib/node_modules/strongloop/node_modules/rx/dist/rx.js:77
    throw e;
    ^
true

Any hints? Thanks!

And selection the model to create the relationship from:

bug major

Most helpful comment

Published as [email protected]

All 94 comments

@JordanMajd are you using node6?

@JordanMajd this is my console log of latest version of generator-loopback:
node6

I am using node5. 5 and I don't see your error,

(node:31096) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

this warning is suspected, find some related issue : https://github.com/sequelize/cli/issues/291
Can you try with node5 and see if the error still exists?

Hey @jannyHou ,

I am using Node 6. Good call. I will try out a 5.* and see how it goes.

Thanks.

I'm seeing this same (or very similar) issue on 4.4.3. I do not get the first error:

(node:31096) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

But I do get the last error:

/usr/local/lib/node_modules/strongloop/node_modules/rx/dist/rx.js:77
throw e;
^
true

@nateha1984 could you fork https://github.com/strongloop/loopback-sandbox and upload your code?
I fail to reproduce it on my end...seems it's not as simple as you create a model in an app then just establish a relation. it might be caused by other config.

and please also include your generator-loopback, loopback version:) Thanks.

I've uploaded my changes to https://github.com/nateha1984/loopback-sandbox

I've been following the loopback-getting-started tutorial and run into the error on this page of the docs: https://docs.strongloop.com/display/public/LB/Define+model+relations

loopback version: 2.28.0
generator-loopback version: 1.20.6

@nateha1984 I git cloned your repo and followed tutorial on the doc page:
A coffee shop has many reviews
review

but it still works fine, did I miss anything or steps?

No, that's about it. I've tried running through another 3rd party tutorial as well and had the same issue.

I haven't had a chance to retest with another version of Node, but do you think system could be a factor?

I'm on:

@JordanMajd mine is windows. I am testing on mac now, need sometime to setup lol.

I'm also on OSX, same version

@JordanMajd @nateha1984 thank you I reproduced that error on osx.

I am facing the same error on windows.
Any help to resolve to this will be much appreciated.
Thank you.

@Arveti good to know that it also happens on windows. could you post your system info(win7?8?10?) and strongloop & generator-loopback version? Thanks.

Let me know if there is anything I can do to hlep @jannyHou

@jannyHou It's windows 7. Npm version - 3.3.12, strongloop - 6.0.0, generator-loopback - 1.20.6

Hello I have the same problem

C:\Users\mrjordan\AppData\Roaming\npm\node_modulesstrongloop\node_modules\rx\dist\rx.js:77
throw e;
^
true

The running environment is: Windows7, I upgraded to [email protected] and these are the rest of versions:
{ 'loopback-server': '1.0.
npm: '3.8.9',
ares: '1.10.1-DEV',
http_parser: '2.5.2',
icu: '56.1',
modules: '46',
node: '4.4.4',
openssl: '1.0.2h',
uv: '1.8.0',
v8: '4.5.103.35',
zlib: '1.2.8' }

Could somebody help me with this issue?.

Regards.

I label it as a major issue, we will take a look at it as soon as possible. As a workaround, anyone run into this bug please check our doc https://docs.strongloop.com/display/public/LB/Tutorial%3A+model+relations
or example https://github.com/strongloop/loopback-example-relations
to manually add relations. Thanks for understanding.

Same issue here

Linux RHEL7.2
Node v4.4.3
strongloop v6.0.0 (node v4.4.3)
β”œβ”€β”€ [email protected] (fb756f2)
β”œβ”€β”€ [email protected] (8a73f8b)
β”œβ”€β”€ [email protected] (cc2e089)
β”œβ”€β”€ [email protected] (62e539b)
β”œβ”€β”€ [email protected] (6ab604c)
β”œβ”€β”€ [email protected] (f46e58f)
β”œβ”€β”€ [email protected] (55d9a35)
β”œβ”€β”¬ [email protected] (254835a)
β”‚ └── [email protected] (ec2d95b)
β”œβ”€β”€ [email protected] (c53788b)
β”œβ”€β”€ [email protected]
└── [email protected]

? Select the model to create the relationship from: Grupo
? Relation type: has many
? Choose a model to create a relationship with: Tag
? Enter the property name for the relation: (tags)

node-v4.4.3-linux-x64/lib/node_modules/strongloop/node_modules/generator-loopback/node_modules/yeoman-generator/node_modules/yeoman-environment/node_modules/inquirer/node_modules/rx/dist/rx.js:77
throw e;
^
true

It seems something is missing here node-v4.4.3-linux-x64/lib/node_modules/strongloop/node_modules/generator-loopback/lib/helpers.js:

exports.checkRelationName = function (modelDefinition, name, callback) {

  modelDefinition.properties(function(err, list) {
    if (err) callback(err);
    var conflict = list.some(function(property) {
      return property.name === name;
    });
    if (conflict) {
      callback('Same property name already exists: ' + name);
    } else {
      callback(true);
    }

  });

conflict is always false and callback throws an error.

@jannyHou - Same issue here...

Console log --
C:\Sites\temps\loopback-server>slc loopback:relation ? Select the model to create the relationship from: dishes ? Relation type: has many ? Choose a model to create a relationship with: Comments ? Enter the property name for the relation: (comments)

C:\Users\juguar\AppData\Roaming\npm\node_modules\strongloop\node_modules\generator-loopback\node_modules\yeoman-generator\node_modules\yeoman-environment\node_modules\inquirer\node_modules\rx\dist\rx.js:77 throw e; ^ true

package.json --
"dependencies": { "compression": "^1.0.3", "cors": "^2.5.2", "helmet": "^1.3.0", "loopback": "^2.22.0", "loopback-boot": "^2.6.5", "loopback-component-explorer": "^2.4.0", "loopback-connector-mongodb": "^1.15.1", "loopback-datasource-juggler": "^2.39.0", "serve-favicon": "^2.0.1" }

Windows 10, 64-bit
[email protected]

have the same issue

i am using:

strongloop v6.0.0 (node v4.4.4)
β”œβ”€β”€ [email protected] (fb756f2)
β”œβ”€β”€ [email protected] (a98f310)
β”œβ”€β”€ [email protected] (9b29df0)
β”œβ”€β”€ [email protected] (62e539b)
β”œβ”€β”€ [email protected] (6ab604c)
β”œβ”€β”€ [email protected] (f8c2339)
β”œβ”€β”€ [email protected] (28c261d)
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] (ec2d95b)
β”œβ”€β”€ [email protected] (c53788b)
β”œβ”€β”€ [email protected]
└── [email protected]

with OS windows 8.1

hope you can fix this problem soon

Same issue here...Latest StrongLoop, both Node 4.4.4 and Node 6.1, Windows 10.

Same issue here! OSX El Capitan

same issue here using node v0.12..7

have the same issue

strongloop v6.0.1 (node v6.1.0)
β”œβ”€β”€ [email protected] (fb756f2)
β”œβ”€β”€ [email protected] (a98f310)
β”œβ”€β”€ [email protected] (9b29df0)
β”œβ”€β”€ [email protected] (62e539b)
β”œβ”€β”€ [email protected] (6ab604c)
β”œβ”€β”€ [email protected] (f8c2339)
β”œβ”€β”€ [email protected] (28c261d)
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] (ec2d95b)
β”œβ”€β”€ [email protected] (c53788b)
β”œβ”€β”€ [email protected]
└── [email protected]
with OS Mac OSX El Capitan

same error on Mac OSX El Capitan

I am getting similar error too,
screen shot 2016-05-13 at 9 30 13 pm

Any suggestions on how to fix this?

Same Error.
OSX El Capitan

strongloop v6.0.1 (node v4.4.3)
β”œβ”€β”€ [email protected] (fb756f2)
β”œβ”€β”€ [email protected] (a98f310)
β”œβ”€β”€ [email protected] (9b29df0)
β”œβ”€β”€ [email protected] (62e539b)
β”œβ”€β”€ [email protected] (6ab604c)
β”œβ”€β”€ [email protected] (f8c2339)
β”œβ”€β”€ [email protected] (28c261d)
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] (ec2d95b)
β”œβ”€β”€ [email protected] (c53788b)
β”œβ”€β”€ [email protected]
└── [email protected]

I have the same error on Cloud9

/home/ubuntu/.nvm/versions/node/v4.4.3/lib/node_modules/strongloop/node_modules/generator-loopback/node_modules/yeoman-generator/node_modules/yeoman-environment/node_modules/inquirer/node_modules/rx/dist/rx.js:77
    throw e;
    ^
true
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected])
β”œβ”€β”€ [email protected] ([email protected])
β”œβ”€β”€ [email protected] ([email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

Experiencing the same issue on linux with several nodejs versions.

getting the same using v4.4.4 on OSX Yosemite

I am able to reproduce it on my machine too:

  1. create a new project, e.g. via yo loopback
  2. define two models, e.g. Customer and Address
  3. run yo loopback:relation

(Node v6.1.0, the latest generator-loopback and loopback-workspace from GitHub master.)

+1
getting exact problem on node 5.11.1 as well as 6.10.0 on Ubuntu 14.04

/home/awsp/.nvm/versions/node/v5.11.1/lib/node_modules/strongloop/node_modules/rx/dist/rx.js:77
    throw e;
    ^
true

For a temp fix you can

  • navigate to where slc is installed and find
  • for npm 2 would be <YOUR_GLOBAL_NPM_FOLDER>/strongloop/node_modules/generator-loopback/node_modules/yeoman-generator/
  • install npm install [email protected] which would bring inquirer back to 0.11

if you're using yo or npm3 then i assume you can do the equivalent

problem is urgent!

Apologies for closing temporarily, wrong button. It's 4AM and I'm accidentally closing issues. That is my queue to go to bed.

I'm using Ubuntu 16.04, node 4.4.4 and loopback 6.0.0 and same issue here. Updated to newer version of loopback but error persists.

_Status update_

@jannyHou is working on this and will hopefully have a fix for you guys soon.

I have same error. I'm using ArchLinux, kernel: 4.5.4-1, node version: v4.4.4, npm version: 3.9.0.
I have test with node 6.0 and i receive same error, but not receive this error on OSX El Capitan node version: 4.4..3 and npm version: 2.15.1

I also have the same problem on Ubuntu 15.04 with Node v5.9.0, npm 3.7.3
How to manually add a relation?

I also have the same issue on OSX EL Capitan node V4.4.4.

You can define the relationship like so on the model.json file

"relations": {
"reviews": {
"type": "hasMany",
"model": "Review",
"foreignKey": ""
},
"reviewers": {
"type": "hasMany",
"model": "Reviewer",
"foreignKey": ""
}
},

Please refer to the article
https://docs.strongloop.com/display/public/LB/Define+model+relations

@kajanth that is a temporary work around that works, Thank You. Note that the model.json file is actually item.json for the example being using.

See:

We really could use a permanent fix so that the apic loopback:relation command actually works without throwing an error.

Running npm ls -g --depth=1 2>/dev/null | grep inquirer

I get the following

β”‚ β”œβ”€β”€ [email protected]
β”‚ β”œβ”€β”€ [email protected]
β”‚ β”œβ”€β”€ [email protected]
β”‚ β”œβ”€β”€ [email protected]
β”‚ β”œβ”€β”€ [email protected]

From the notes above it appears that the issue may be in either [email protected] or [email protected] as someone mentioned that we need to have inquirer-0.11. I am not sure which version API Connect currently uses however.

https://github.com/strongloop/generator-loopback/pull/187 landed. Please verify it:

  1. In a loopback app, run slc loopback:relation to create a relation, make sure it exits successfully and the new relationship entry is created into commom/models/model_name.json
  2. In a apic app, run apic loopback:relation and verify the same thing as step 1.

I attempted to reinstall strong loop to get this fix. It did not work. How do I get the fix for this issue?

Same Issue I am also facing...any solution..?

ashwani@ashwani:~/workspacenode/api$ slc loopback:relation
? Select the model to create the relationship from: user
? Relation type: has many
? Choose a model to create a relationship with: Order
? Enter the property name for the relation: (orders)

/opt/node-v4.4.3-linux-x64/lib/node_modules/strongloop/node_modules/generator-loopback/node_modules/yeoman-generator/node_modules/yeoman-environment/node_modules/inquirer/node_modules/rx/dist/rx.js:77
throw e;
^
true
ashwani@ashwani:~/workspacenode/api$ cd
ashwani@ashwani:~$ node --version
v4.4.3
ashwani@ashwani:~$ slc --version
strongloop v6.0.1 (node v4.4.3)
β”œβ”€β”€ [email protected] (fb756f2)
β”œβ”€β”€ [email protected] (a98f310)
β”œβ”€β”€ [email protected] (9b29df0)
β”œβ”€β”€ [email protected] (62e539b)
β”œβ”€β”€ [email protected] (6ab604c)
β”œβ”€β”€ [email protected] (f8c2339)
β”œβ”€β”€ [email protected] (28c261d)
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] (ec2d95b)
β”œβ”€β”€ [email protected] (c53788b)
β”œβ”€β”€ [email protected]
└── [email protected]

ashwani@ashwani:~$ npm --version
2.15.1

@MemoryChips , @ashishtilara yes I believe this is not published to npm yet, it is only on CI, once its verified we will be able to push it live, in the mean while you would still have to use the workarounds listed above.

/cc @cgole

Verified 
lavens-mbp:test laven$ slc loopback:relation
? Select the model to create the relationship from: customer
? Relation type: has many
? Choose a model to create a relationship with: order
? Enter the property name for the relation: orders
? Optionally enter a custom foreign key: 
? Require a through model? No
lavens-mbp:test laven$ 
  "validations": [],
  "relations": {
    "orders": {
      "type": "hasMany",
      "model": "order",
      "foreignKey": ""
    }
lavens-mbp:test2 laven$ apic loopback:relation
? Select the model to create the relationship from: customer
? Relation type: has many
? Choose a model to create a relationship with: order
? Enter the property name for the relation: orders
? Optionally enter a custom foreign key: 
? Require a through model? No
Done running loopback generator
  "validations": [],
  "relations": {
    "orders": {
      "type": "hasMany",
      "model": "order",
      "foreignKey": ""
    }

@laven26 thanks. I will close it after it's published

Thank you @davidcheung

Published as [email protected]

Are we still waiting for a new release on npm to address this? I understand its not a massive issue as we can manually write the relations, but its nice for basic models and sleepy programming. I can still recreate the issue.

@robcresswell and everyone still runs into this problem:
Please reinstall generator-loopback globally from https://registry.npmjs.org/
npm install -g generator-loopback

I am closing it since it's fixed by the latest version of generator-loopback.
Please reinstall generator-loopback globally from https://registry.npmjs.org/ to get it work :)
npm install -g generator-loopback

How can I reinstall the generator-loopback

??

You can't wait to get started, huh?

npm update -g --depth 1 generator-loopback should do the trick when you have installed strongloop

I got an error when I tried the above command.
Rob

$ npm update -g --depth 1 generator-loopback
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead!
npm ERR! Linux 3.13.0-37-generic
npm ERR! argv "/home/rob/n/bin/node" "/home/rob/n/bin/npm" "update" "-g" "--depth" "1" "generator-loopback"
npm ERR! node v5.6.0
npm ERR! npmΒ  v3.6.0

npm ERR! Cannot read property 'target' of null
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!Β Β Β Β  https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR!Β Β Β Β  /home/rob/Documents/Training/Loopback/loopback-ang2/client/npm-debug.log

On Friday, May 27, 2016 4:23 PM, kaktus42 <[email protected]> wrote:

You can't wait to get started, huh?npm update -g --depth 1 generator-loopback should do the trick when you have installed strongloopβ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Try a reinstall of the whole strongloop package, @MemoryChips

The only difference now is that instead of an error the 'slc loopback:relation' command hangs with '[object Promise]' where previously it threw the error.

Well.. For me it works with the new version.
So they must have done something right...

Well, it's changed, but still failing. This was on a full reinstall of the local and global packages.

npm v3.9.5
node v6.2.0

Unfortunately it working for you isn't much use to me :)

I have the same @robcresswell problem, the 'slc loopback:relation' command hangs with '[object Promise]'. I have OS X El Capitan , node V5.10.1 and np, 3.8.3.
This is my terminal

? Select the model to create the relationship from: dishes
? Relation type: has many
? Choose a model to create a relationship with: Comments
? Enter the property name for the relation: (comments)

[object Promise]

Somebody have a idea what is the problem and which is the solution? Thanks in advance.

I got to create a relationship, only after reinstalling the global strongloop.

@medvar72 I am using OS X EI Capitan 10.11.3, node 4.4.3, npm 2.15.1
Could you try reinstall strongloop?
And I will update to your node & npm version to see if i can reproduce that problem.

hi, @jannyHou, thanks for your response. I have reinstalled the strongloop with "npm install strongloop -g", too I did it with node and npm, and when try execute the command "slc loopback:relation" I get the same result:

? Select the model to create the relationship from: dishes
? Relation type: has many
? Choose a model to create a relationship with: Comments
? Enter the property name for the relation: (comments)

[object Promise]

Please tell if you need some extra info.

Regards.

@medvar72 I am using the same npm, node, generator-loopback with you now, but relation generator works fine for me:

jannyHous-MacBook-Pro:testrelationfix jannyhou$ slc loopback:relation
thisNewDir/Users/jannyhou/lb/triage/testrelationfix
? Select the model to create the relationship from: Note
? Relation type: has many
? Choose a model to create a relationship with: Note
? Enter the property name for the relation: notes
? Optionally enter a custom foreign key: 
? Require a through model? No

generator-loopback: 1.20.6

jannyHous-MacBook-Pro:testrelationfix jannyhou$ npm -v
3.8.3
jannyHous-MacBook-Pro:testrelationfix jannyhou$ node -v
v5.10.1
jannyHous-MacBook-Pro:testrelationfix jannyhou$ 

@medvar72 The problem seems like generator doesn't recognize a returned promise. Could you check if bluebird is installed properly in your generator-loopback?

Hi @jannyHou , here the results of the verification:
[🍺 hector@Hectors-MBP loopback-server]$ npm list bluebird -g
/usr/local/lib
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected]
└─┬ [email protected]
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected]
└─┬ [email protected]
└── [email protected]

I did a fresh install of strongloop again with the command "npm install strongloop -g" and the results of installation looks ok, but the command "slc loopback: relation" is not working yet . Here I'd attached my terminal log.

terminal.rtf.zip

Thanks.

I'm having the same problem ([object Promise]). Posting my environment to help.
Windows 10

npm -v
3.9.2
node -v
v4.4.5
npm list bluebird -g
+-- [email protected]
| `-- [email protected]
`-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  `-- [email protected]
    `-- [email protected]
slc -v
strongloop v6.0.1 (node v4.4.5)
β”œβ”€β”€ [email protected] (fb756f2)
β”œβ”€β”€ [email protected] (a98f310)
β”œβ”€β”€ [email protected] (9b29df0)
β”œβ”€β”€ [email protected] (62e539b)
β”œβ”€β”€ [email protected] (6ab604c)
β”œβ”€β”€ [email protected] (f8c2339)
β”œβ”€β”€ [email protected] (28c261d)
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] (ec2d95b)
β”œβ”€β”€ [email protected] (81311b3)
β”œβ”€β”€ [email protected]
└── [email protected]

@felcerreia @medvar72 @robcresswell I reproduced the error with a reinstalled strongloop.
I am not sure why a generator-loopback inside strongloop fails to return the promise properly, maybe due to the flatten structure of npm3, but a globally installed generator-loopback works fine.

So as a workaround. Please delete the generator-loopback inside your stongloop and npm install -g generator-loopback.

Hi @jannyHou I followed your instruction but the error continues showing, then I'd uninstalled both strongloop and generator-loopback , and reinstalled strongloop again. It is not working yet. Any suggest?
[🍺 hector@Hectors-MBP loopback-server]$ npm ls -g --depth=0
/usr/local/lib
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]

Thanks in advance

@medvar72 It fails because I submitted a pr to yeoman-generator to use [email protected] for [email protected].
My previous fix works for the latest yeoman-environment but seems doesn't work with 1.5.3.
As a workaround, please try to install the latest yeoman-environment in strongloop's depedency.
I will fix it as soon as possible.

Thanks a lot, it is working!.

Regards

I tried uninstalling yeoman-environment, yeoman-generator, strongloop, and loopback-generator, then installing them all back (in that order) and it didn't work, still getting Object Promise when using loopback:relation

I tried manually updating the yeoman-environment to 1.6.1 but the problem [Object Promise] isn't solved

Here's what I did (os x):

  1. npm install -g strongloop - update strongloop to v6.0.1 globally
  2. npm install -g generator-loopback - install v1.20.7 globally
  3. npm install -g yeoman-environment - install yeoman-environment v1.6.1 globally
  4. rmdir -rf /usr/local/lib/node_modules/strongloop/node_modules/yeoman-environment - removed the local yeoman-environment dependency shipped with strongloop, forcing it to use the global v1.6.1.

slc loopback:relation
? Select the model to create the relationship from: CoffeeShop
? Relation type: has many
? Choose a model to create a relationship with: Review
? Enter the property name for the relation: (reviews)

[object Promise]

After several attempts to update globally yeoman-environment, yeoman-generator, I found the fix. The culprit is in yeoman-environment inside yeoman-generator. Thanks for the hint by @jannyHou .Fixed by
1) updating the yeoman-environment version explictly in package.json
strongloopnode_modulesgenerator-loopbacknode_modules\yeoman-generator\package.json

"yeoman-environment": "1.6.1",
  1. rerun npm install in the same folder

Thanks Janny

Related: https://github.com/strongloop/loopback/issues/2392
Verification done for [object Promise] issue-fix by @ssh24. PTAL at verification comments.

Verified.

Verification steps:

  • [x] Create a slc loopback app
  • [x] Create two models test1 and test2 using slc loopback:model
  • [x] Create a has many relationship between test1 and test2 using slc loopback:relation as shown below:

010616 -bash 80x24 terminal today at 10 46 09 am

After that the test1.json file includes the following details as expected:

test-1 json sublime text today at 11 25 18 am

Hi good morning everyone

Are the fixes above are in npm registry? Are do we need to manually update package.jaon file for yeoman generator before doing npm install -g loopback-generator?

@subchal The fix hasn't released, it will be in npm registry tomorrow.
Please check workaround:
https://github.com/strongloop/loopback/issues/2292#issuecomment-222576398

Published as [email protected]

It looks like this has broken more of the generator now.
Creating a new model, I can no longer add properties.

See below where I've tried to create a new model "Contact" and add a property called "email".

`? Enter the model name: Contact
? Select the data-source to attach undefined to: db (memory)
? Select model's base class PersistedModel
? Expose Contact via the REST API? Yes
? Custom plural form (used to build REST URL):
? Common model or server only? common
Let's add some Contact properties now.

Enter an empty property name when done.
? Property name:
>> Name cannot contain special characters [object Object]email
`

Hi Good afternoon Maujee - Glad I didn't download the latest version :) I followed the trick another user posted here to update the package.json in the yeoman-generator

@0candy could you take a look of the new error of model generator:
https://github.com/strongloop/loopback/issues/2292#issuecomment-223397865

I am afraid the CI doesn't catch the error..
Related change: https://github.com/strongloop/generator-loopback/commit/4a70425563df8190c6448b14fa1359ae0f340216#diff-27a1c86133de4310373decfdad200a91R105
Thanks.

I have the same error as like this, please do help to rectify it

Enter an empty property name when done.
? Property name:

Name cannot contain special characters [object Object]

The same thing happens with relations

? Select the model to create the relationship from: Organisation
? Relation type: has many
? Choose a model to create a relationship with: OrgUser
? Enter the property name for the relation: orgUsers
? Optionally enter a custom foreign key: 
>> Name cannot contain special characters [object Object]orgUserId


@maujee we are verifying the fix:
https://github.com/strongloop/generator-loopback/commit/cfbdedad07df6b77684403f381981036a4171113

I will update here after the fix published to npm registry.

@jannyHou Thanks for the update.

The error is fixed and published in [email protected]
https://github.com/strongloop/generator-loopback/commit/f257078b4f340434b0bcfc201d2758861733a7c7

Please reinstall your generator-loopback to get it work.

I am closing issue here since generator looks good now :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Overdrivr picture Overdrivr  Β·  3Comments

bajtos picture bajtos  Β·  4Comments

ImanMh picture ImanMh  Β·  4Comments

htmlauthor picture htmlauthor  Β·  3Comments

nmklong picture nmklong  Β·  3Comments