草庐IT

node.js - 从 module.exports 中的另一个函数调用 module.exports 中的 "local"函数?

如何从module.exports声明中的另一个函数中调用一个函数?应用程序.jsvarbla=require('./bla.js');console.log(bla.bar());bla.jsmodule.exports={foo:function(req,res,next){return('foo');},bar:function(req,res,next){this.foo();}}我正在尝试从函数bar中访问函数foo,我得到:TypeError:Object#hasnomethod'foo'如果我将this.foo()更改为foo()我会得到:ReferenceError:f

git - 在 Heroku 上创建 Node.js 应用程序时,我应该将文件夹 "node_modules" checkin Git 吗?

我在这里遵循了关于Heroku上Node.js的基本入门说明:https://devcenter.heroku.com/categories/nodejs这些指令没有告诉你创建一个.gitignorenode_modules,因此暗示文件夹node_modules应该被checkin到Git。当我在Git存储库中包含node_modules时,我的入门应用程序运行正常。当我遵循更高级的示例时:BuildingaReal-time,PolyglotApplicationwithNode.js,Ruby,MongoDBandSocket.IOhttps://github.com/mongo

git - 在 Heroku 上创建 Node.js 应用程序时,我应该将文件夹 "node_modules" checkin Git 吗?

我在这里遵循了关于Heroku上Node.js的基本入门说明:https://devcenter.heroku.com/categories/nodejs这些指令没有告诉你创建一个.gitignorenode_modules,因此暗示文件夹node_modules应该被checkin到Git。当我在Git存储库中包含node_modules时,我的入门应用程序运行正常。当我遵循更高级的示例时:BuildingaReal-time,PolyglotApplicationwithNode.js,Ruby,MongoDBandSocket.IOhttps://github.com/mongo

node.js - 如何使用 node_modules 中本地安装的包中的可执行文件?

如何在node.js中使用本地版本的模块。例如,在我的应用中,我安装了coffee-script:npminstallcoffee-script这会将其安装在./node_modules中,而coffee命令位于./node_modules/.bin/coffee中。当我在项目的主文件夹中时,有没有办法运行这个命令?我想我正在寻找类似于bundleexecinbundler的东西。基本上,我想指定一个涉及项目的每个人都应该使用的CoffeeScript版本。我知道我可以添加-g标志来全局安装它,这样咖啡在任何地方都可以正常工作,但是如果我想为每个项目提供不同版本的咖啡怎么办?

node.js - 如何使用 node_modules 中本地安装的包中的可执行文件?

如何在node.js中使用本地版本的模块。例如,在我的应用中,我安装了coffee-script:npminstallcoffee-script这会将其安装在./node_modules中,而coffee命令位于./node_modules/.bin/coffee中。当我在项目的主文件夹中时,有没有办法运行这个命令?我想我正在寻找类似于bundleexecinbundler的东西。基本上,我想指定一个涉及项目的每个人都应该使用的CoffeeScript版本。我知道我可以添加-g标志来全局安装它,这样咖啡在任何地方都可以正常工作,但是如果我想为每个项目提供不同版本的咖啡怎么办?

node.js - 如何使用 Node.js 解决 "Cannot find module"错误?

从GitHub拉下一个模块并按照说明构建它后,我尝试使用以下方法将其拉入现有项目:>npminstall../faye这似乎可以解决问题:>npmlist/home/dave/src/server└─┬faye@0.7.1├──cookiejar@1.3.0├──hiredis@0.1.13└──redis@0.7.1但是Node.js找不到模块:>nodeapp.jsnode.js:201throwe;//process.nextTickerror,or'error'eventonfirsttick^Error:Cannotfindmodule'faye'atFunction._re

node.js - 如何使用 Node.js 解决 "Cannot find module"错误?

从GitHub拉下一个模块并按照说明构建它后,我尝试使用以下方法将其拉入现有项目:>npminstall../faye这似乎可以解决问题:>npmlist/home/dave/src/server└─┬faye@0.7.1├──cookiejar@1.3.0├──hiredis@0.1.13└──redis@0.7.1但是Node.js找不到模块:>nodeapp.jsnode.js:201throwe;//process.nextTickerror,or'error'eventonfirsttick^Error:Cannotfindmodule'faye'atFunction._re

node.js - Docker 容器中缺少 `node_modules`

我正在使用以下Dockerfile为我的Node.js应用程序构建一个dockerdocker镜像:FROMkeymetrics/pm2:latestRUNapkadd--no-cache--updatealpine-sdkpython#BundleAPPfilesCOPYpackage.json.#InstallappdependenciesENVNPM_CONFIG_LOGLEVELwarnRUNnpminstallRUNnpmrebuildbcrypt--build-from-sourceCOPY..#ShowcurrentfolderstructureinlogsRUNls-a

node.js - Docker 容器中缺少 `node_modules`

我正在使用以下Dockerfile为我的Node.js应用程序构建一个dockerdocker镜像:FROMkeymetrics/pm2:latestRUNapkadd--no-cache--updatealpine-sdkpython#BundleAPPfilesCOPYpackage.json.#InstallappdependenciesENVNPM_CONFIG_LOGLEVELwarnRUNnpminstallRUNnpmrebuildbcrypt--build-from-sourceCOPY..#ShowcurrentfolderstructureinlogsRUNls-a

node.js - 如何将 node_modules 文件夹从 docker 容器中复制到构建机器上?

我正在将应用程序移至新的构建管道。在CI上,我无法安装Node来完成NPM安装步骤。我的想法是将npminstall步骤移至使用Node的Docker镜像,安装Node模块并将Node模块复制回主机,以便另一个进程可以打包应用程序。这是我的Dockerfile:FROMnode:9#CreateappdirectoryRUNmkdir-p/usr/src/appWORKDIR/usr/src/app#InstallappdependenciesCOPY./dashboard-interface/package.json/usr/src/app/RUNnpminstall--silent