Nodejs代码无法在Windows10上构建,但可以在MacOS上运行。可能是什么原因?

时间:2018-12-28 21:33:31

标签: node.js reactjs autodesk-forge autodesk-viewer

我正在尝试在Windows10上从https://github.com/Autodesk-Forge/forge-rcdb.nodejs构建和部署代码

在MacOS上,我已经在开发环境中成功构建了它,现在我正在尝试使其在Windows上实现。在Windows上,我遵循了相同的步骤:

 $env:NODE_ENV = "developement"
 $env:HOT_RELOADING="true"
 npm start

但是我的Powershell显示:

> forge-rcdb@4.0.0 start D:\Documents\forge-rcdb.nodejs

> node bin/start.js

internal/modules/cjs/loader.js:583

    throw err;

    ^

Error: Cannot find module '../../config/developement.config.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (D:\Documents\forge-rcdb.nodejs\node_modules\c0nfig\index.js:10:14)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.require.extensions.(anonymous function) [as .js] (D:\Documents\forge-rcdb.nodejs\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! forge-rcdb@4.0.0 start: `node bin/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the forge-rcdb@4.0.0 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\yangdihan\AppData\Roaming\npm-cache\_logs\2018-12-28T21_12_28_942Z-debug.log
PS D:\Documents\forge-rcdb.nodejs> npm install cairo
npm ERR! code E404
npm ERR! 404 Not Found: cairo@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\yangdihan\AppData\Roaming\npm-cache\_logs\2018-12-28T21_20_30_522Z-debug.log

这可能是由于Windows使用反斜杠而不是路径的斜杠造成的吗?

2 个答案:

答案 0 :(得分:0)

好像developement有一个错字(development)并导致了错误:

Error: Cannot find module '../../config/developement.config.js'

将环境设置为config文件夹中的相应配置文件,否则c0nfig库将无法找到配置:

config -
       |--- development.config.js
       |--- production.config.js

答案 1 :(得分:0)

我终于解决了。 解决方案是安装Python2.7,C ++编译器,c#编译器。只需使用Visual Studio安装程序安装它们就可以了。 然后很可能需要按照以下说明修复npm canvas / cairo:https://github.com/benjamind/delarre.docpad/blob/master/src/documents/posts/installing-node-canvas-for-windows.html.md

然后一切正常