loopback icon indicating copy to clipboard operation
loopback copied to clipboard

slc loopback:relation throws error

Open JordanMajd opened this issue 10 years ago • 94 comments

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:

JordanMajd avatar May 04 '16 07:05 JordanMajd

@JordanMajd are you using node6?

jannyHou avatar May 04 '16 14:05 jannyHou

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

jannyHou avatar May 04 '16 15:05 jannyHou

Hey @jannyHou ,

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

Thanks.

JordanMajd avatar May 04 '16 15:05 JordanMajd

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 avatar May 04 '16 15:05 nateha1984

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

jannyHou avatar May 04 '16 15:05 jannyHou

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 avatar May 04 '16 16:05 nateha1984

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

jannyHou avatar May 04 '16 17:05 jannyHou

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

nateha1984 avatar May 04 '16 18:05 nateha1984

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 avatar May 04 '16 18:05 JordanMajd

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

jannyHou avatar May 04 '16 18:05 jannyHou

I'm also on OSX, same version

nateha1984 avatar May 04 '16 19:05 nateha1984

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

jannyHou avatar May 04 '16 19:05 jannyHou

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

Arveti avatar May 05 '16 16:05 Arveti

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

jannyHou avatar May 05 '16 18:05 jannyHou

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

JordanMajd avatar May 05 '16 19:05 JordanMajd

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

Arveti avatar May 06 '16 10:05 Arveti

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.

mjordang avatar May 06 '16 18:05 mjordang

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.

jannyHou avatar May 06 '16 23:05 jannyHou

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 avatar May 07 '16 01:05 andmart

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.

andmart avatar May 07 '16 02:05 andmart