Node.js 使用NodeJs';在Windows上开发并构建在Linux上的代码上发出咕噜声?

Node.js 使用NodeJs';在Windows上开发并构建在Linux上的代码上发出咕噜声?,node.js,gruntjs,cross-platform,phantomjs,mocha.js,Node.js,Gruntjs,Cross Platform,Phantomjs,Mocha.js,如何使用nodejs构建跨平台项目 我在Windows上开发,但我的代码库构建在基于Linux的CI服务器上。它使用Grunt构建前端,并需要几个nodejs模块 Nodejs要求在本地将模块安装到项目中,以便grunt.task.loadNpmTasks加载。问题是,我必须从某个地方安装它们,无论是Windows还是Linux,当我从其中一个安装时,另一个就无法工作 我的项目所需的列表模块在本地安装如下: npm install connect-livereload --production

如何使用nodejs构建跨平台项目

我在Windows上开发,但我的代码库构建在基于Linux的CI服务器上。它使用Grunt构建前端,并需要几个nodejs模块

Nodejs要求在本地将模块安装到项目中,以便grunt.task.loadNpmTasks加载。问题是,我必须从某个地方安装它们,无论是Windows还是Linux,当我从其中一个安装时,另一个就无法工作

我的项目所需的列表模块在本地安装如下:

npm install connect-livereload --production
npm install time-grunt --production
npm install load-grunt-tasks --production
npm install jshint-stylish --production
npm install load-grunt-tasks --production
npm install grunt-contrib-copy --production
npm install grunt-contrib-concat --production
npm install grunt-contrib-uglify --production
npm install grunt-contrib-compass --production
npm install grunt-contrib-jshint --production
npm install grunt-contrib-cssmin --production
npm install grunt-contrib-connect --production
npm install grunt-contrib-clean --production
npm install grunt-contrib-htmlmin --production
npm install grunt-contrib-imagemin --production
npm install grunt-contrib-watch --production
npm install grunt-rev --production
npm install grunt-usemin --production
npm install grunt-mocha --production
npm install grunt-exec --production
npm install grunt-open --production
npm install grunt-svgmin --production
npm install grunt-concurrent --production
npm install grunt-ember-templates --production
npm install grunt-replace --production
npm install grunt-neuter  --production
如果我从Windows安装它,然后从Windows在项目文件夹上运行
grunt
,它仍然可以正常工作。如果我随后将代码签入git并在linux框中编译,则chmod 777和chown将发送给我的用户,并运行相同的
grunt
命令。它失败了,出现了如下错误:

Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
Fatal error: spawn ENOENT
我运行了
npm安装
,它开始失败,并显示另一条消息:

Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html

/home/administrator/platform/frontend/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261
  throw err;
        ^
Error: spawn ENOENT
    at errnoException (child_process.js:998:11)
    at Process.ChildProcess._handle.onexit (child_process.js:789:34)
我所做的一切都不能使它起作用

因此,从Linux框中,我从我的项目中删除了整个node_modules目录,并重新运行上面的安装命令。现在,所有这些都可以在Linux上完美运行

然后我将其签入git并在Windows中签出。然后我转到项目文件夹并运行
grunt
,然后它失败,原因是:

Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html

Running PhantomJS...ERROR
>> 'c:\Users\Edy' is not recognized as an internal or external command,
 0 [ '\'c:\\Users\\Edy\' is not recognized as an internal or external command,\r',
>>   'operable program or batch file.' ]
>> operable program or batch file. 1 [ '\'c:\\Users\\Edy\' is not recognized as an internal or external command,\r',
>>   'operable program or batch file.' ]
Warning: PhantomJS exited unexpectedly with exit code 1. Use --force to continue.
卸载phantomjs并在本地安装没有帮助。全局安装也没有帮助。因此,让它在Windows上工作的唯一方法似乎是删除node_modules dir并在Windows上重新安装,这就引出了Linux上的第一个问题

有没有办法在我这样的跨平台环境中使用nodejs?我真不敢相信我是第一个有这样一套的人呵呵


在此方面的任何提示或帮助都将不胜感激。谢谢

node.js中的许多依赖项都使用本机插件。当您
npm安装时,
会为您的特定环境编译本机加载项

如果要在环境之间移动,可以
npm rebuild
为新环境重建这些二进制文件。或者以更长的方式,删除
node\u modules
文件夹,然后再次安装
npm


致命错误:spawn enoint
表示试图生成的流程节点不存在。一个常见的情况是,当尝试生成为另一个环境编译的二进制文件时,它所期望的二进制文件不存在。

哦,伙计,谢谢,
npm rebuild
是我所缺少的。。。工作得很有魅力!