Nodejs代码无法在Windows10上构建,但在MacOS上工作.可能是什么原因



我正在尝试从 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:Documentsforge-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:Documentsforge-rcdb.nodejsnode_modulesc0nfigindex.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:Documentsforge-rcdb.nodejsnode_modulesbabel-registerlibnode.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:UsersyangdihanAppDataRoamingnpm-cache_logs2018-12-28T21_12_28_942Z-debug.log
PS D:Documentsforge-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:UsersyangdihanAppDataRoamingnpm-cache_logs2018-12-28T21_20_30_522Z-debug.log

这可能是因为 Windows 有反斜杠而不是路径斜杠造成的?

看起来development有一个拼写错误( developement ) 并导致了错误:

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

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

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

我最终解决了。解决方案是安装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

然后一切正常

最新更新