使用grunt压缩图像

我安装了node,npm,然后grunt。然后,我尝试在Gruntfile.Js中压缩写下面的代码的图片: grunt.initConfig({ responsive_images: { dev: { options: { engine: 'im', sizes: [{ width:800 , suffix:'_large_1x' , quality: 30 }] }, 和我的HTML文件中的img如下所示: <img src="images_src/still_life-800_large_1x.jpg"> 然而,当我刷新网页时,我检查了开发人员工具中的“networking”,图片“无法响应数据”!

WebPush UnauthorizedRegistration 400尝试从节点Js发送推送通知时出错

我正尝试使用来自NodeJS的Web Push发送推送通知。 以下是我在前端获取订阅的方式: swRegistration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: "SOME_APPLICATION_PUBLIC_KEY" })….. 这里是我用来发送推送通知的NodeJS: const webpush = require('web-push'); const options = { vapidDetails: { subject: 'mailto:SOME_MAIL_ID', publicKey: 'SOME_PUBLIC_KEY', privateKey: 'SOME_PRIVATE_KEY' } }; const pushSubscription = {"endpoint":"https://fcm.googleapis.com/fcm/send/SOME_END_POINT","keys{"p256dh":"SOME VALUE","auth":"SOME_VALUE"}}; webpush.sendNotification(pushSubscription, "Test Notification", options) .then(function(response) { console.log(response) }) .catch(function(error) {console.log(error)}); 然后我得到一个400错误。 我已经交叉validation了我的gcm_sender_id和我的服务器密钥。 一切看起来不错,通知在Firefox中testing正常工作,并在Chrome中失败。 这是我得到的错误: name: 'WebPushError', message: 'Received unexpected response code', statusCode: […]

Multer数组只返回一个文件

我正在使用multer在数据库中存储多个文件。 这些文件正确地存储在我的数据库,但是,如果我打印req.files我只得到一个文件。 这是我的代码: var storage = GridfsStorage({ url: config.mongo.uri, filename(req, file, cb) { cb(null, file.originalname); }, metadata(req, file, cb) { cb(null, {owner: req.params.driver}) } }); var upload = multer({ storage: storage }).array('files[]'); return upload(req, res, function (err) { if(err) { handleError(err); } console.log(req.files); // –> Getting only one file, even thought it stores all of […]

不同的babel预设为后端和前端,但为相同的env

我有nodejs项目与反应前端部分,我想使用巴贝尔后端服务器(有导入/导出,和一些额外的function,如“装饰”,对象rest传播等) 此外,我想使用巴贝尔反应前端项目,但与不同的预置/插件集。 在后台我有最新的(8.2)nodejs,所以它已经知道类,asynchronous/等待等不应该被转移。 但在前端,我针对IE11,所以我必须启用大量的插件。 所以,如果我有单一的.babelrcconfiguration前端和后端我越来越transpiled后端代码。 我知道有一个'env'选项为babelconfiguration,但在描述的情况下,我有相同的'env'。 现在我结束了两个configuration:一个在package.json和一个在webpack.config(babel-loader选项)里面。 不过,我不喜欢结果,因为它可能会混淆新的开发者。 他可以在package.json里面findbabelconfiguration,并认为这是唯一的configuration,试图添加/修改某些东西,并努力为什么它不影响前端部分。 这样的设置也有一些问题: Jest无法从webpack.config中读取babel设置,所以我必须在.babelrc中定义额外的“env”:“test”,只是为了开玩笑。 这在testing过程中导致不必要的后端传输。

Request-Promise使用async / await抛出“no auth mechanisms defined”

我只是尝试asynchronous/等待request-promise并遇到这个错误: RequestError: Error: no auth mechanism defined at new RequestError (node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:188:22) at Auth.onRequest (node_modules/request/lib/auth.js:133:18) at Request.auth (node_modules/request/request.js:1360:14) at Context.<anonymous> (test/routes.js:37:41) From previous event: at Request.plumbing.init (node_modules/request-promise-core/lib/plumbing.js:36:28) at Request.RP$initInterceptor [as init] (node_modules/request-promise-core/configure/request2.js:41:27) at new Request (node_modules/request/request.js:130:8) at request (node_modules/request/index.js:54:10) at Context.<anonymous> (test/routes.js:37:24) 这是我最近build立的API端点,它应该在MongoDB中创build一个新的用户。 它使用Passport策略提供的基本身份validation,并且使用Postmantesting了它的工作原理。 我不确定为什么这个错误被抛出。 […]

不能更新npm(缺less访问权限)

打破我的头来克服这个错误。 我试过每个论坛,但仍然找不到合适的解决scheme。 我也卸载并重新安装npm,仍然是同样的问题。 请救救我! npm错误 并且 日志 TA!

async调用基类的构造函数之后,无法在子类上设置属性。 NodeJS v8.2.1

你可以请帮忙了解什么可能是错误,而在父类的callback中使用承诺,然后尝试设置子类的属性? 我正在使用nodejs v8.2.1 这里是基类的例子: class CGLBase extends CAuthClient { constructor(req, res) { return new Promise(resolve => { super(req, res, (authClient) => { this.setAuthClient(authClient); resolve(this); }); }); } setAuthClient(authClient) { //setting authClient (this.auth will contain property) } } 这里的子类的例子: class СSheet extends CGLBase { constructor(document, urlRequest, urlResponse) { super(urlRequest, urlResponse); this.document = document; this.someAnotherProp = "some […]

npm开始不刷新保存在一台计算机上的新内容,但在另一台上,几乎完全相同的设置

我有我的工作电脑这是一个Windows 10专业版,我的笔记本电脑是一个Windows 10家庭。 在同一个项目上工作: push和pull Git。 通过Udemy学习反应。 两台电脑都使用Chrome。 在Windows上的Ubuntu上使用Bash和最新的更新。 两者都使用ConEmu作为控制台。 npm -v = 3.10.10 。 两个node -v = 6.11.2 。 硬件明显不同,但不确定是否相关和值得上市。 无论如何,我正在玩的这个初学者项目,当我对其进行更改并且npm start正在运行时,您可以在控制台中看到活动,在浏览器中进行刷新,并且所做的任何更改都会反映出来。 在笔记本电脑上,这个过程不起作用。 在控制台中进行更改,保存,没有任何活动,浏览器刷新不反映更改。 必须重新启动npm start才能体现更改。 有点恼人的至less可以说。 无论如何,想什么可能会导致这个? 真的没有遇到任何东西在我的谷歌努力。

鉴于以下文件结构,如何运行基本的量angular器testing?

我一直在试图按照这里给出的教程。 但是,当我尝试开始量angular器testing,没有testing似乎运行。 然而,我的webdriverpipe理器似乎运行完美。 基本上没有任何反应。 我已经尝试了以下内容: node protractor conf.js node node_modules/protractor conf.js node node_modules/protractor node_modules/protractor/conf.js node node_modules/protractor node_modules/protractor/tests/conf.js 这些工作都没有,第一个抛出一个错误。 我试图把文件的副本放在多个目录中,但是这些文件都不起作用。 我不确定问题是什么,但这是多less文件设置。 ui_directory/ <– This is the overall directory for my web projects ui_directory/conf.js ui_directory/todo-spec.js ui_directory/node_modules/ ui_directory/node_modules/protractor/ ui_directory/node_modules/protractor/conf.js ui_directory/node_modules/protractor/todo-spec.js ui_directory/node_modules.protractor/tests/ ui_directory/node_modules.protractor/tests/conf.js ui_directory/node_modules.protractor/tests/todo-spec.js 究竟是从教程中运行testing的正确命令是什么? 所有的todo-spec.js和conf.js文件都是一样的。 我的conf.js文件包含以下内容: exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['todo-spec.js'] };

Skype:Bot没有回复

我正在用Bot生成器框架开发我的第一个NodeJS bot。 僵尸在模拟器上成功运行,但当我注册僵尸程序,并试图在Skypetesting – 它不回复任何东西。 更多信息 在Bot注册期间,我给了ngrok.exe给出的端点url和附加的“/ api / messages” 我在网上添加了Skype频道 – bot节目 app.js(包含restify)&ngrok都在localhost上运行 我在连接器里面添加了Microsoft App Id,如下所示: “` var connector = new builder.ChatConnector({ //appId: process.env.MICROSOFT_APP_ID, //appPassword: process.env.MICROSOFT_APP_PASSWORD appId: MY APP ID HERE, appPassword: MY APP PASSWORD HERE }); “` 任何帮助表示赞赏! 很高兴提供更多的细节,如果需要的话。