在Windows 10上构建Autodesk Forge RCDB失败,并出现Node-gyp错误 [英] Building Autodesk Forge RCDB on Windows 10 fails with node-gyp errors

查看:140
本文介绍了在Windows 10上构建Autodesk Forge RCDB失败,并出现Node-gyp错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试构建Forge响应连接数据库时.我无法在Windows 10计算机上构建此应用程序.我无法成功运行"npm install".我收到以下错误,如下所示.我最终尝试使用预先配置的画布",但它仍然没有让节点应用程序运行.

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/安装--- 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

推荐答案

以下是我在装有Windows10的两台不同的两台不同计算机上测试的完整安装和设置步骤.

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

预安装:

  1. Node.js-使用 v.6. x v8.x
  2. Node.js全局软件包:

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

  • npm-windows-upgrade(链接):
    • 此工具将移动npm并将其安装到Windows的特殊文件夹%appdata%中.
    • 安装步骤:
      • Administrator身份打开Powershell并执行Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force.
      • 通过npm install --global --production npm-windows-upgrade npm-windows-upgrade
      • 安装工具
      • 在Powershell中执行cmd npm-windows-upgrade --npm-version 5.6.0(注意.您可以选择所需的任何版本,例如6.0.1 )
      • 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)
          • 此工具将安装软件包node-gyp所需的构建工具.
          • 安装将需要一些时间来等待构建工具被下载和安装.如果您可能首先看到消息Successfully installed Python 2.7,但是必须等待消息Successfully installed Visual Studio Build Tools.出现.
          • Administrator身份打开Powershell并通过npm install --global --production windows-build-tools
          • 安装工具
          • 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
          • 运行npm install时,软件包node-canvas需要此工具.
          • 正常打开Powershell(例如当前用户)并通过npm install -g node-gyp
          • 安装工具
          • 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

          Visual Studio 2017(链接):

          Visual Studio 2017 (link):

          • 这可能是可选的,在我的案例中,我刚刚安装了VS C ++功能.
          • This might be optional, I just installed it with VS C++ features in my cases.

          巧克力(链接):

          • 此工具将使您在Windows上安装软件包node-canvas的依赖项更加容易.
          • Administrator身份打开Powershell并执行Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')).
          • 在安装Chocolatey之后,通过choco install -y python2 gtk-runtime microsoft-build-tools libjpeg-turbo安装node-canvas依赖项(您可能会看到一条警告消息visuallstudiotool-vs2017 installation failed,您可以忽略它.对于我来说,它没有影响结果 )
          • 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)

          带有开罗库的GTK(

          GTK with cairo library (link):

          • 此工具是软件包node-canvas必需的依赖项.
          • 安装步骤:
            • This tool the required dependency for package node-canvas.
            • Installation steps:
              • Download precompiled X64 GTK package here.
              • Unzip all contents into C:\GTK.

              Mongochef(链接):

              Mongochef (link):

              • 此工具将使您更轻松地恢复伪造rcdb的虚拟数据库.

              MongoDB:

              • 您可以按照此处在您的计算机上安装MongoDB,或改用MongoDB PaaS mlab .
              • You can follow the instructions here to install MongoDB on your compture , or use MongoDB PaaS mlab instead.

              主要安装:

              1. 下载 forge-rcdb 的源代码,并将其解压缩到您的某个位置喜欢.在我的情况下,我将其放入桌面.
              2. 正常打开Powershell(例如,当前用户),然后将目录更改为源代码的未压缩文件夹.例如,在Powershell中执行cd Desktop\forge-rcdb-nodejs-master.
              3. 在源代码文件夹的根目录中运行cmd npm install. (您在编译软件包node-canvas时可能会看到一些错误消息,但是同时可以看到'copied xxx.c','copied xxx.cpp'等,那么您可以忽略这些错误.就我而言,运行forge-rcdb并不是问题.)
              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.)

              配置:

              1. 使用编辑器打开config\development.config.js并将viewer部分的值更改为:

              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'
              }
              

            • 使用MongoDB连接设置更改config\development.config.js中的database部分.

            • Change the database section in the config\development.config.js with you MongoDB connection settings.

              通过 Mongochef 的导入在resources/db/devresources/db/prod中恢复虚拟数据库数据.功能.

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

              正常打开Powershell(例如当前用户)并设置以下环境变量:

              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"
              

            • 运行项目

              1. 将Powershell的当前目录更改为forge-rcdb的源代码文件夹,然后键入npm start

              在您喜欢的浏览器中打开 http://localhost:3000 .

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

              故障排除

              1. 您可能无法在浏览器中加载任何模型.如果要测试功能,请将resources\models\prod\robot复制到resources\models\dev\robot.然后,在Web浏览器中导航到 http://localhost:3000/configurator ,然后在项目,然后您将在屏幕上看到加载的模型.

              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.

              如果看到 http://localhost:3000/api/forge/的响应用户从浏览器开发者控制台显示 HTTP EORROR 404 (HTTP EORROR CODE 404),那么您必须检查Forge应用的 CallBack URL 是否用于托管forge-rcdb在 Forge Dev Protal 中是

              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)

              • 此后,您或您的用户必须使用Autodesk帐户登录网站,才能从Forge OAuth服务获取3条腿标记,然后才能在图库页面中上传模型.

              如果您从 Mongochef 将数据库内容resources\db\dev\configurator.models.json导入到MongoDB中. (注意.请参阅配置部分的第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)

              如果您无法从网页上加载任何列出的模型,则表示您的resources\models\prodresources\models\dev以及Forge OSS存储桶中没有下载的可见气泡.因此,请检查数据库中的urn值是否在前面提到的这些位置中具有这些模型.

              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.

              如果您发现故障排除"第3项的主要原因是您没有在forge-rcdb中列出的模型,那是因为这些模型是Autodesk的私有模型或之前由其他用户自己上传的模型,不幸的是,可能无法与公众共享. 要解决此问题,您必须将配置部分第3步中提到的MongoDB集合的示例数据更改为您自己的模型.

              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.

              希望有帮助.

              这篇关于在Windows 10上构建Autodesk Forge RCDB失败,并出现Node-gyp错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆