1

While attempting to get the Forge Responsive Connected Database to build. I am unable to build this application on my Windows 10 machine. I am unable to succesffuly run “npm install”. I get the following errors as listed below. I ended up trying to use a pre-configured “canvas” and it still didn’t let the node app run.

https://github.com/Autodesk-Forge/forge-rcdb.nodejs

I have tried these solutions to no success:

https://github.com/npm/npm/issues/14543

https://github.com/nodejs/node-gyp#on-windows

https://github.com/Automattic/node-canvas/wiki/Installation---Windows

https://github.com/substack/dnode/issues/181

https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

https://www.npmjs.com/package/canvas-prebuilt

> canvas@1.6.10 install D:\DEVELOPMENT\Autodesk\forge-rcdb.nodejs3\node_modules\canvas
> node-gyp rebuild


D:\DEVELOPMENT\Autodesk\forge-rcdb.nodejs3\node_modules\canvas>if not defined npm_config_node_gyp (node "C:\Users\steck\AppData\Roaming\nvm\v7.7.1\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
module.js:472
    throw err;
    ^

Error: Cannot find module 'D:\DEVELOPMENT\Autodesk\forge-rcdb.nodejs3\node_modules\canvas\node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:425:7)
    at startup (bootstrap_node.js:146:9)
    at bootstrap_node.js:540:3
SteckDEV
  • 489
  • 4
  • 13
  • Have you tried to use `Chocolatey` to install those dependencies of `node-canvas`? It required `choco install -y python2 gtk-runtime microsoft-build-tools libjpeg-turbo` and GTK compiled with cario. – Eason Kang May 10 '18 at 08:37
  • You might have to installed Visual Studio 2017 firstly. One of the above packages require `vs-buildtoo-2017`. BTW, my nodejs is `v6.10.2`. – Eason Kang May 10 '18 at 08:39
  • 1) I have installed Visual Studio 2017. 2) I have run the choco install successfully. I am even able to run the `node-gyp rebuild` outside of the node-gyp and it succeeds. However when I run npm install it fails with the above error. – SteckDEV May 10 '18 at 13:40
  • Have you tried to delete `node_module` and rerun `npm install` again? If it is persistent, please check pre-requirements of node tools (`node-gyp` and `windows-build-tools` ) are installed globally on your computer. This is important to `node-canvas`. – Eason Kang May 10 '18 at 14:37
  • Here is the additional dependencies installation guide of the `node-gyp` on windows: https://github.com/nodejs/node-gyp#option-1 – Eason Kang May 10 '18 at 14:41
  • I just tested those steps on a clean installed windows 10 and it works. If you still have trouble somewhere, please let me know. If needed, we can back to the Forge Help and contunue there. – Eason Kang May 10 '18 at 14:56
  • 1
    I have provided my installation steps below, please have a try! – Eason Kang May 11 '18 at 04:13

1 Answers1

2

Here are the full installation and setup steps I tested on two different 2 different computers with Windows10 installed.

Pre-Installations:

  1. Node.js - used v.6.x and v8.x
  2. Node.js global packages:

    • npm-windows-upgrade(link):
      • This tool will move and install npm into Windows' spectial folder %appdata%.
      • Installation steps:
        • Open Powershell as Administrator and execute Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force.
        • Install tool by npm install --global --production npm-windows-upgrade npm-windows-upgrade
        • Execute cmd npm-windows-upgrade --npm-version 5.6.0 in the Powershell (note. you can choose any version what you want, e.g. 6.0.1)
    • windows-build-tools(link):
      • This tool will install build tools required by the package node-gyp.
      • The installation will take some time to wait for the build tools to be downloaded and installed. If you might see a message Successfully installed Python 2.7 firstly, but you have to wait for the message Successfully installed Visual Studio Build Tools. shows up.
      • Open Powershell as Administrator and install tool by npm install --global --production windows-build-tools
    • node-gyp(link):
      • This tool is required by the package node-canvas while running npm install.
      • Open Powershell normally(say current user) and install tool by npm install -g node-gyp
  3. Visual Studio 2017 (link):

    • This might be optional, I just installed it with VS C++ features in my cases.
  4. Chocolatey (link):

    • This tool will make your life easier to install dependencies for package node-canvas on Windows.
    • Open Powershell as Administrator and execute Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')).
    • After installing Chocolatey, install node-canvas dependencies by choco install -y python2 gtk-runtime microsoft-build-tools libjpeg-turbo (You might see a warning message visuallstudiotool-vs2017 installation failed and you can ignore it. In my cases, it didn't affect the result)
  5. GTK with cairo library (link):

    • This tool the required dependency for package node-canvas.
    • Installation steps:
      • Download precompiled X64 GTK package here.
      • Unzip all contents into C:\GTK.
  6. Mongochef (link):

    • This tool will make your life easier to restore dummy database of the forge-rcdb.
  7. MongoDB:

    • You can follow the instructions here to install MongoDB on your compture , or use MongoDB PaaS mlab instead.

Main Installations:

  1. Download source codes of the forge-rcdb and unzip into somewhere you like. In my cases, I put it into my desktop.
  2. Open Powershell normally(say current user) and change directory into the unzipped folder of the source code. For instance, execute cd Desktop\forge-rcdb-nodejs-master in the Powershell.
  3. Run cmd npm install in the root of the source code folder. (You may see some error message while compiling the package node-canvas, but can see 'copied xxx.c', 'copied xxx.cpp', and so on in the same time, then you can ignore the errors. In my cases, it didn't be a problem to run forge-rcdb.)

Configurations:

  1. Open config\development.config.js with your editor and change values of viewer section into:

    viewer: {
          viewer3D: 'https://developer.api.autodesk.com/derivativeservice/v2/viewers/viewer3D.js?v=4.0.1',
          threeJS:  'https://developer.api.autodesk.com/derivativeservice/v2/viewers/three.js?v=4.0.1',
          style:    'https://developer.api.autodesk.com/derivativeservice/v2/viewers/style.css?v=4.0.1'
    }
    
  2. Change the database section in the config\development.config.js with you MongoDB connection settings.

  3. Restore dummy database data in the resources/db/dev or resources/db/prod via Mongochef's Import function.

  4. Open Powershell normally(say current user) and set following environment variables:

    $env:NODE_ENV="development"
    $env:HOT_RELOADING="true"
    $env:FORGE_DEV_CLIENT_ID="YOUR_CLINET_ID"
    $env:FORGE_DEV_CLIENT_SECRET="YOUR_CLINET_SECRET"
    

Run the project

  1. Change current directory of the Powershell into the source code folder of the forge-rcdb and type npm start

  2. open http://localhost:3000 in your favorite browser.

Trouble Shooting

  1. You might be not able to load any models in the browser. If you to test the functionality, please copy resources\models\prod\robot into resources\models\dev\robot. Afterward, navigate to http://localhost:3000/configurator in the web browser and mouse-click on Kinematics project, then you will see the model loaded on your screen.

  2. If you see the response of http://localhost:3000/api/forge/user showing HTTP EORROR CODE 404 from the browser dev console, then you must have to check whether the CallBack URL of your Forge App used to host forge-rcdb in Forge Dev Protal is http://localhost:3000/api/forge/callback/oauth. (note. This config can be changed in config\development.config.js)

    • Afterward, you or your users must have to log into the website with Autodesk account to obtain 3 legged token from the Forge OAuth service to upload models in the gallery page.
  3. If you get an empty array from the response of http://localhost:3000/api/models/configurator?limit=100&offset=0&search=, it means there is nothing in your MongoDB collection configurator.models. To fix this issue, you can import db content resources\db\dev\configurator.models.json into your MongoDB via Mongochef. (note. Please refer the step 3 of the configuration section)

  4. If you cannot load any listed models from the web pages, it means there is not downloaded viewable bubbles in your resources\models\prod or resources\models\dev as well as your Forge OSS bucket. So, please check the urn value in your database whether you have those models in these positions previously mentioned.

  5. If you found the main reason for item 3 of Trouble Shooting is that you didn't own models listed in the forge-rcdb, that's because these models are Autodesk's private models or uploaded by other users themselves before, that might not be shared to the public, unfortunately. To fix this issue, you have to change the example data of MongoDB Collections mentioned in step 3 of the configuration section to your own models.

Hope it helps.

Eason Kang
  • 6,155
  • 1
  • 7
  • 24
  • That was perfect. I was able to get it the application. However now i have two issues. 1) "http://localhost:3000/api/forge/user" gives me a "404 Not Found" I have created an app at http://developer.autodesk.com and used the client id/secret found after creating that app into the $env:FORGE_DEV_CLIENT_ID ="###" then also $env:FORGE_DEV_CLIENT_SECRET ="###" 2) The models have been copied to the dev\robot however they still do not load when clicking on the model. – SteckDEV May 11 '18 at 23:05
  • I actually think the issue may be with http://localhost:3000/api/models/configurator?limit=100&offset=0&search= I am only getting back []. However when I look at the same behavior at https://forge-rcdb.autodesk.io/configurator I get an entire list of items back. – SteckDEV May 11 '18 at 23:36
  • I added some troubleshooting to my answer above, please take a look. – Eason Kang May 12 '18 at 10:49
  • Do you have similar steps for a clean Linux machine to setup as a server? Is there an easy process for a Elastic Beanstalk or do you guys usually setup a new linux machine? – SteckDEV May 22 '18 at 04:05
  • @EasonKang just wondering why these instruction is not listed in the repository's read me file? – Afshin Jun 26 '18 at 01:40
  • @Afshin Most of our team members are using Unix like OS, this might be the main reason why this is not listed in the README.md, but this just is a guess. Thank you for your feedback, I will take time to make a PR to update the readme file, or you can do it yourself. :) – Eason Kang Jun 26 '18 at 02:19
  • @SteckDEV Sorry for the late, we have lots of backlog in the queue. Most of the installation steps are the same, you just have to take care about the dependencies of the `node-canvas`, and replace Powershell commands to corresponding Terminal commands such as `bash`. Here are the setup instructions of different OS for the `node-canvas`: https://github.com/Automattic/node-canvas/wiki#desktop – Eason Kang Jun 26 '18 at 02:25