iTwin/imodel-unity-example

Workflow doesn't work

daisy1188 opened this issue · 2 comments

hi guys, I'm trying to reproduce your workflow to view ITwin models with Unity. I followed the YouTube tutorial step by step but the process doesn't work for me. I leave you below the steps that I perform with the cmd and the consequent errors that derive from it:


C:\Users\davpo>git clone https://github.com/imodeljs/imodel-unity-example.git
fatal: destination path 'imodel-unity-example' already exists and is not an empty directory.

C:\Users\davpo>git clone https://github.com/imodeljs/imodel-unity-example.git
Cloning into 'imodel-unity-example'...
remote: Enumerating objects: 273, done.
remote: Counting objects: 100% (82/82), done.
remote: Compressing objects: 100% (63/63), done.
Rremote: Total 273 (delta 43), reused 43 (delta 19), pack-reused 191eceiving objects:  88% (241/273),
Receiving objects:  89% (243/273),
Receiving objects: 100% (273/273), 17.19 MiB | 7.40 MiB/s, done.
Resolving deltas: 100% (129/129), done.

C:\Users\davpo>cd C:\Users\davpo\imodel-unity-example\node

C:\Users\davpo\imodel-unity-example\node>dir
 Il volume nell'unità C è OS
 Numero di serie del volume: 5409-411F

 Directory di C:\Users\davpo\imodel-unity-example\node

22/07/2021  12:18    <DIR>          .
22/07/2021  12:18    <DIR>          ..
22/07/2021  12:18               809 ci_pipeline.yml
22/07/2021  12:18        33,570,816 demo.bim
22/07/2021  12:18             2,487 IModelRpc.proto
22/07/2021  12:18           722,534 package-lock.json
22/07/2021  12:18             1,678 package.json
22/07/2021  12:18         3,627,520 protoc.exe
22/07/2021  12:18    <DIR>          src
22/07/2021  12:18               273 tsconfig.json
22/07/2021  12:18                53 tslint.json
               8 File     37,926,170 byte
               3 Directory  88,808,083,456 byte disponibili

C:\Users\davpo\imodel-unity-example\node>npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

> @bentley/imodeljs-native@2.16.1 postinstall C:\Users\davpo\imodel-unity-example\node\node_modules\@bentley\imodeljs-native
> node ./installNativePlatform.js

npm install --no-save @bentley/imodeljs-win32-x64@2.16.1
+ @bentley/imodeljs-win32-x64@2.16.1
updated 1 package in 5.508s
found 0 vulnerabilities




> core-js@2.6.12 postinstall C:\Users\davpo\imodel-unity-example\node\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> core-js-pure@3.13.0 postinstall C:\Users\davpo\imodel-unity-example\node\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"


> highlight.js@9.18.5 postinstall C:\Users\davpo\imodel-unity-example\node\node_modules\highlight.js
> node deprecated.js

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  Verion 9 of Highlight.js has reached EOL.  It will no longer
  be supported or receive security updates in the future.
  Please upgrade to version 10 or encourage your indirect
  dependencies to do so.

  For more info:

  https://github.com/highlightjs/highlight.js/issues/2877
  https://github.com/highlightjs/highlight.js/blob/master/VERSION_10_UPGRADE.md

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

> core-js@3.13.0 postinstall C:\Users\davpo\imodel-unity-example\node\node_modules\oidc-client\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> protobufjs@6.10.2 postinstall C:\Users\davpo\imodel-unity-example\node\node_modules\protobufjs
> node scripts/postinstall

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\mocha\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 896 packages from 858 contributors and audited 905 packages in 33.459s

92 packages are looking for funding
  run `npm fund` for details

found 6 vulnerabilities (2 low, 4 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details

C:\Users\davpo\imodel-unity-example\node>npm run build

> imodel-unity-example@ build C:\Users\davpo\imodel-unity-example\node
> cpx src/IModelRpc_pb.js lib/ && npm run build-code 1>&2


> imodel-unity-example@ build-code C:\Users\davpo\imodel-unity-example\node
> tsc 1>&2


C:\Users\davpo\imodel-unity-example\node>npm start

> imodel-unity-example@ start C:\Users\davpo\imodel-unity-example\node
> node lib/Main.js --snapshotFile=demo.bim

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module '@bentley/presentation-common'
Require stack:
- C:\Users\davpo\imodel-unity-example\node\node_modules\@bentley\electron-manager\lib\common\ElectronRpcManager.js
- C:\Users\davpo\imodel-unity-example\node\node_modules\@bentley\electron-manager\lib\backend\ElectronHost.js
- C:\Users\davpo\imodel-unity-example\node\node_modules\@bentley\electron-manager\lib\ElectronBackend.js
- C:\Users\davpo\imodel-unity-example\node\lib\IModelHubDownload.js
- C:\Users\davpo\imodel-unity-example\node\lib\Main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (C:\Users\davpo\imodel-unity-example\node\node_modules\@bentley\electron-manager\lib\common\ElectronRpcManager.js:12:31)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\davpo\\imodel-unity-example\\node\\node_modules\\@bentley\\electron-manager\\lib\\common\\ElectronRpcManager.js',
    'C:\\Users\\davpo\\imodel-unity-example\\node\\node_modules\\@bentley\\electron-manager\\lib\\backend\\ElectronHost.js',
    'C:\\Users\\davpo\\imodel-unity-example\\node\\node_modules\\@bentley\\electron-manager\\lib\\ElectronBackend.js',
    'C:\\Users\\davpo\\imodel-unity-example\\node\\lib\\IModelHubDownload.js',
    'C:\\Users\\davpo\\imodel-unity-example\\node\\lib\\Main.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! imodel-unity-example@ start: `node lib/Main.js --snapshotFile=demo.bim`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the imodel-unity-example@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\davpo\AppData\Roaming\npm-cache\_logs\2021-07-22T10_20_58_787Z-debug.log

C:\Users\davpo\imodel-unity-example\node>

Can you tell me where I'm wrong?

Hi @daisy1188,

I observed the same result. I worked around it by doing as npm suggested - installing the peer dependencies myself. In the node directory:

npm install --save-dev "@bentley/imodeljs-frontend@^2.16.0"
npm install --save-dev "@bentley/presentation-common@^2.16.0"

Note: I do not have Unity installed so I was only able to verify that the iModel.js portion of the app appears to start successfully.

[js  6:52:06.39] D:\js\s\unity-example\node>npm start

> imodel-unity-example@ start D:\js\s\unity-example\node
> node lib/Main.js --snapshotFile=demo.bim

Info    |imodel-unity-example| Attempting to open demo.bim
Info    |imodel-unity-example| demo.bim opened successfully
Info    |imodel-unity-example| Listening on ws://localhost:3005

@mgooding can the package.json be cleaned up so that npm install will install all required dependencies?

Thanks @daisy1188 for reporting this issue. #21 fixes the problem and a pull from master should now work out of the box.

Thanks @pmconne for diagnosing and providing a workaround while I was out of the office.