Skip to content

slc loopback:relation throws error #2292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JordanMajd opened this issue May 4, 2016 · 94 comments
Closed

slc loopback:relation throws error #2292

JordanMajd opened this issue May 4, 2016 · 94 comments
Assignees

Comments

@JordanMajd
Copy link

JordanMajd commented May 4, 2016

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:

@jannyHou jannyHou self-assigned this May 4, 2016
@jannyHou
Copy link
Contributor

jannyHou commented May 4, 2016

@JordanMajd are you using node6?

@jannyHou
Copy link
Contributor

jannyHou commented May 4, 2016

@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 : sequelize/cli#291
Can you try with node5 and see if the error still exists?

@JordanMajd
Copy link
Author

Hey @jannyHou ,

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

Thanks.

@nateha1984
Copy link

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

@jannyHou
Copy link
Contributor

jannyHou commented May 4, 2016

@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.

@nateha1984
Copy link

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

@jannyHou
Copy link
Contributor

jannyHou commented May 4, 2016

@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?

@nateha1984
Copy link

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

@jannyHou jannyHou added bug and removed triaging labels May 4, 2016
@JordanMajd
Copy link
Author

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:

@jannyHou
Copy link
Contributor

jannyHou commented May 4, 2016

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

@nateha1984
Copy link

I'm also on OSX, same version

@jannyHou
Copy link
Contributor

jannyHou commented May 4, 2016

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

@Arveti
Copy link

Arveti commented May 5, 2016

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

@jannyHou
Copy link
Contributor

jannyHou commented May 5, 2016

@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.

@JordanMajd
Copy link
Author

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

@Arveti
Copy link

Arveti commented May 6, 2016

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

@mjordang
Copy link

mjordang commented May 6, 2016

Hello I have the same problem

C:\Users\mrjordan\AppData\Roaming\npm\node_modules\strongloop\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.

@jannyHou jannyHou added the major label May 6, 2016
@jannyHou
Copy link
Contributor

jannyHou commented May 6, 2016

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.

@andmart
Copy link

andmart commented May 7, 2016

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

@andmart
Copy link

andmart commented May 7, 2016

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.

@jaredcasto
Copy link

jaredcasto commented May 7, 2016

@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]

@toni783
Copy link

toni783 commented May 8, 2016

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

@random0000
Copy link

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

@nobesio
Copy link

nobesio commented May 11, 2016

Same issue here! OSX El Capitan

@denkan
Copy link

denkan commented Jun 1, 2016

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.

@erickyi2006
Copy link

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
    strongloop\node_modules\generator-loopback\node_modules\yeoman-generator\package.json
"yeoman-environment": "1.6.1",
  1. rerun npm install in the same folder

Thanks Janny

@jannyHou jannyHou added #tob and removed #tob labels Jun 1, 2016
@jannyHou jannyHou assigned ssh24 and unassigned ssh24 Jun 1, 2016
@gunjpan
Copy link
Contributor

gunjpan commented Jun 1, 2016

Related: #2392
Verification done for [object Promise] issue-fix by @ssh24. PTAL at verification comments.

@ssh24
Copy link
Contributor

ssh24 commented Jun 1, 2016

Verified.

Verification steps:

  • Create a slc loopback app
  • Create two models test1 and test2 using slc loopback:model
  • 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

@subchal
Copy link

subchal commented Jun 1, 2016

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?

@jannyHou
Copy link
Contributor

jannyHou commented Jun 1, 2016

@subchal The fix hasn't released, it will be in npm registry tomorrow.
Please check workaround:
#2292 (comment)

@0candy
Copy link
Contributor

0candy commented Jun 1, 2016

Published as [email protected]

@maujee
Copy link

maujee commented Jun 2, 2016

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
`

@subchal
Copy link

subchal commented Jun 2, 2016

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

@jannyHou
Copy link
Contributor

jannyHou commented Jun 3, 2016

@0candy could you take a look of the new error of model generator:
#2292 (comment)

I am afraid the CI doesn't catch the error..
Related change: strongloop/generator-loopback@4a70425#diff-27a1c86133de4310373decfdad200a91R105
Thanks.

@baabuaravind
Copy link

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]

@maujee
Copy link

maujee commented Jun 3, 2016

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


@jannyHou
Copy link
Contributor

jannyHou commented Jun 3, 2016

@maujee we are verifying the fix:
strongloop/generator-loopback@cfbdeda

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

@maujee
Copy link

maujee commented Jun 3, 2016

@jannyHou Thanks for the update.

@jannyHou
Copy link
Contributor

jannyHou commented Jun 3, 2016

The error is fixed and published in [email protected]
strongloop/generator-loopback@f257078

Please reinstall your generator-loopback to get it work.

@jannyHou
Copy link
Contributor

jannyHou commented Jun 8, 2016

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

@jannyHou jannyHou closed this as completed Jun 8, 2016
@jannyHou jannyHou removed the #tbr label Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests