NodeJs – Fluent-FFMPEG找不到FFMPEG

情况: 在windows和nodejs上用fluent-ffmpeg和ffmpeg运行mp3-to-video。 用于启动服务器的命令:nodemon server.js启动时,执行mp3-to-videofunction。 然后调用fluent-ffmpeg,我将其debugging到fluent-ffmpeg无法find我的ffmpeg包的行。 我确实添加了一些系统variables。 包括FFMPEG_PATH,包括PATH,以及所有不同的目录,如ffmpeg \和ffmpeg \ lib \ 我不知道该怎么办..我得到这个错误: Error: Cannot findd ffmpeg at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\processor.js:136:22 at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\capabilities.js:123:9 at C:\Users\lexha\Desktop\nodejs\node_modules\async\dist\async.js:421:16 at next (C:\Users\lexha\Desktop\nodejs\node_modules\async\dist\async.js:5302:29) at C:\Users\lexha\Desktop\nodejs\node_modules\async\dist\async.js:906:16 at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\capabilities.js:116:11 at C:\Users\lexha\Desktop\nodejs\node_modules\fluent-ffmpeg\lib\utils.js:223:16 at F (C:\Users\lexha\Desktop\nodejs\node_modules\which\which.js:68:16) at E (C:\Users\lexha\Desktop\nodejs\node_modules\which\which.js:80:29) at C:\Users\lexha\Desktop\nodejs\node_modules\which\which.js:89:16

如何在node.js中创build单例模块?

我正在尝试创build一个在networking上做一些工作的模块,同时也caching最近的结果,以减less它访问的资源的利用率。 我的想法是创build一个模块,并在需要的时候需要它。 然而,在较旧版本的节点中,这被明确地说是无效的,因为如果parsing到相同的path,只requirecaching它的参数。 随着更新版本的节点在node-modules下创build扁平结构,我认为这不再是事实。 不过,我仍然看到更多的关于单身人士的文章,这些文章主张用不同的方法创build一个单身人士: 如果你想创build一个像单例一样的东西,你通常可以在模块中做这样的事情: var HelloWorld = (function () { this.greeting = “Hello, World”; return this; })(); module.exports = HelloWorld; 这意味着如果你在应用程序中多次加载模块,即使在不同的文件中,HelloWorld也只会被调用一次。 并且HelloWorld的所有实例都将指向同一个对象。 首先,我不明白为什么这是真的:如果你从两个不同的目录加载这个模块,为什么HellowWorld只能被调用一次? 不会从被加载的模块的每个不同实例调用一次吗? 其次,如果使用足够新的使用平面安装结构的npm版本,甚至有必要这样做?

如何在谷歌数据存储查询filter处理浮点?

我一直在使用Google DataStore尝试将查询从SQL数据库迁移到DataStore。 我在Node中工作,试图在一个实体上过滤。 该实体具有以下字段。 Exchange: String Threshold: Floating Point Number Pairing: String Userid: String 我可以使用Google云端平台Web视图的按类别查询function成功查询实体。 我目前的代码实现似乎没有返回我想要的正确的响应,虽然我能够作出请求,当我离开阈值filter行。 也build立了适当的指标。 const query = datastore.createQuery('notifications_info') .filter('exchange', '=', objectToRequest.exchange) .filter('threshold', '<=', 0) .filter('threshold', '>', -3) .filter('pairing', '=', objectToRequest.pairing); datastore.runQuery(query,function(error, results){ if(error){ console.log(error); } else if (results){ console.log(results); callback(error, results); } }); 对象要求 var objectToRequest = { exchange: 'gdax', time_interval: 60 […]

如何确定用户在使用护照时注销?

今天开始学习节点,我几乎肯定我的用户没有被正确注销,我不明白为什么。 为了login用户,我在路由文件中写了下面的代码 app.post('/api/signup', passport.authenticate('local-signup', function(err, res, req) { console.log(res); })); 然后在另一个文件这个代码来处理我的用户login的逻辑 passport.serializeUser(function(user, done) { console.log("serializeUser"); console.log(user); done(null, user.id); }); passport.deserializeUser(function(id, done) { console.log("deserializeUser"); console.log(id); User.findById(id, function(err, user) { done(err, user); }); }); passport.use('local-signup', new LocalStrategy( { usernameField: 'username', passwordField: 'password', passReqToCallback: true }, function(req, username, password, done) { console.log(req.sessionID); process.nextTick(function() { User.findOne({ 'local.username': username }, […]

如何使用其他节点项目的node_modules目录

我有一个想法。 比方说,我正在学习angular度,我创造了许多testing项目。 用命令ng new project_name 。 每次我启动这个命令,都需要很多时间来下载和安装node_modules。 我在想什么,我可以使用ng new project_name –skip-install创build项目来创build项目并跳过节点模块安装,稍后我将在我的项目configuration文件(systemjs.config.js) paths: { // paths serve as alias 'npm:': 'node_modules/' <– here I change the path to some other directory }, 使用已安装模块的其他某个项目的node_modules目录。 我试图实现的不是一次又一次地下载相同的模块,也不会减慢我的项目创build时间。

JavaScript:使用时区将UTC时间转换为本地时间

我有一个UTCdate时间string和时区名称。 我从第三方API获取这个。 我需要使用JavaScript / NodeJS将UTC时间转换为该时区的本地时间以及获取该时区的当前时间。 有没有相同的图书馆/方法? var timezone = "America/New_York";//This will always be in Olson format. var UTCTime = "2017-09-03T02:00:00Z"; var localTime; //I need to find the equivalent of UTCTime for America/New_York var currentTime; //Current time of time zone America/New_York

发送一个http请求到一个graphql api时“parsingJSON的问题”

我试图发送一个HTTP请求到Githubs graphql API(V4)。 我的猜测是我的查询格式是错误的。 下面的代码用于向api发送POST请求。 app.get('/fetch-data', function(req, res, next) { const access_token = settings.dev.TOKEN; const query = {query: { viewer: { 'login': 'muckbuck' } }}; const options = { uri: 'https://api.github.com/graphql', method: 'POST', headers: { 'Accept': 'application/json', 'Authorization': "Bearer " + access_token, 'User-Agent': 'request', 'contentType': "application/graphql", }, data: query }; function callback(error, response, body) { […]

Webpack-dev-server找不到要提交的文件

我只是从webpack文档复制粘贴webpack-dev-server + express设置,但是它不起作用,因为服务器找不到要提供的文件。 这个设置有什么问题? server.js const express = require('express'); const webpack = require('webpack'); const webpackDevMiddleware = require('webpack-dev-middleware'); const app = express(); const config = require('../webpack.config.js'); const compiler = webpack(config); app.use(webpackDevMiddleware(compiler, { publicPath: config.output.publicPath })); /*app.use('/',express.static('public')) it works when used insted of webpack dev middleware */ // Serve the files on port 3000. app.listen(3000, function () […]

Sinonfunction存根:如何在模块内调用“自带”function

我正在为node.js代码编写一些unit testing,并使用Sinon通过存根函数调用 var myFunction = sinon.stub(nodeModule, 'myFunction'); myFunction.returns('mock answer'); nodeModule看起来像这样 module.exports = { myFunction: myFunction, anotherF: anotherF } function myFunction() { } function anotherF() { myFunction(); } Mocking对于像nodeModule.myFunction()这样的用例显然nodeModule.myFunction() ,但是我想知道如何在用nodeModule.anotherF()调用时如何在另一个F()内模拟myFunction()调用?

电子协议处理程序不能在Windows上工作

我试图注册一个协议处理程序使用app.setAsDefaultProtocolClient ,我已经得到它在macOS上工作正常,但在Windows 10我得到一个对话说 Error launching app Unable to find Electron app at 'C:\Program Files(x86)\Google\Chrome\Application\60.0.3….. Ect Cannot find module 'C:\Program Files(x86)\Google\Chrome\Application\60.0.3….. Ect 是否正确查看Chrome \ Application文件夹? 如果我使用npm start或使用electron-packager打包的应用程序运行,我会得到同样的错误。 有什么我想念我需要configuration为Windows? 像Mac上的plist? 我一直在寻找,但似乎无法find任何东西。 让我知道任何信息,我可以添加到帮助。