用Laravel灵药临界CSS

我正在使用gulp软件包的关键css ,以前我安装这个软件包: npm install –save critical 但是在运行gulp –production ,npm向我报告这个错误: mix.critical is not a function 这是我完整的gulpfile代码: var elixir = require('laravel-elixir'); var BrowserSync = require('laravel-elixir-browsersync'); var critical = require('critical'); elixir(function(mix) { mix.styles([ "bootstrap.css", "bootstrap-theme.css", "main.css", "jquery.fancybox.css", "font-awesome.css", ]).version("css/all.css") mix.critical({ src: 'http://myapp.dev', css: 'public/css/all.css', width: 1280, height: 600, dest: 'public/css/critical.css' }); }); 为什么npm报告我这个错误?

需要模块并获得空的对象

我已经使用Browserify在浏览器中使用一些节点模块,应该加载require.js,如下所示: 问题是,在定义函数中,我得到了空的对象,任何想法? 我做的是: npm install -g browserify 然后 npm init & npm install lebab –save 创build文件main.js并把下面的代码 var lebab = require("lebab"); 并运行命令 browserify –standalone someName main.js | uglifyjs > bundle.js 它成功完成 把bundle.js文件放在converter / service文件夹下 并试图要求如下: define(["converter/service/bundle"], function (bundle) { 捆绑对象是空的 JS对象,任何想法为什么?

电子:找不到模块“电子预制”

我有一个电子应用程序,使用Nightmare.js时,其中一个button被点击。 它在打包之前工作正常,但是在我用电子打包程序将其编译到.exe文件后,它将按预期工作,直到我点击使用Nightmare.js的button。 我得到这个错误: Uncaught Error: Cannot find module 'electron-prebuilt' at Module._resolveFilename (module.js:470) at Function.Module._resolveFilename (C:\app-directory\app-name-win32-ia32\resources\electron.asar\common\reset-search-paths.js:35) at Function.Module._load (module.js:418) at Module.require (module.js:498) at require (internal/module.js:20) at Object.<anonymous> (C:\app-directory\app-name-win32-ia32\resources\app\node_modules\nightmare\lib\nightmare.js:16) at Object.<anonymous> (C:\app-directory\app-name-win32-ia32\resources\app\node_modules\nightmare\lib\nightmare.js:528) at Module._compile (module.js:571) at Object.Module._extensions..js (module.js:580) at Module.load (module.js:488)

对节点模块进行Jesttesting,忽略目录

您好,我正在尝试使用Jest进行TDD过程来创build节点模块。 我的项目结构看起来像这样 lib目录下: __mocks__ style.scss __tests__ src 我的问题是我想访问__mocks__目录中的style.scss文件,但是当我在debugging模式下运行,我可以看到__mocks__不存在于源中。 只是让你知道我是如何访问它的 /* * Get files directory paths if paths are glob if * not return original * @param {Array} array of file path * @return {Array} array of files found */ const globGetFiles = src => { return new Promise((resolve, reject) => { src = src || […]

如何调整图像大小并使用nodejs中的multer上传到s3并使用easy-image npm模块?

我已经使用下面的代码在nodejs中使用简单的图像npm模块进行图像大小调整。 var easyimg = require('easyimage'); easyimg.rescrop({ src:'1.jpg', dst:'/var/www/html/bangalore.jpg', width:100, height:100 }),function(image,err){ // console.log('Resized and cropped: ' + image.width + ' x ' + image.height); if(image){ console.log(image); } else{ console.log(err); } } 我有成功的输出。 然后,我已经使用下面的代码与multer上传我的图像到s3。 var storage = multerS3({ s3: s3, bucket: 'my_bucket_name', key: function (req, file, cb) { console.log(file); file_name = file.originalname; var newFileName = Date.now() […]

如何使用NodeJS中的http模块在同一端口上打开IPv4和IPv6套接字?

我正在运行以下的NodeJS服务器代码: var express = require('express'); var path = require('path'); var fs = require('fs'); var bodyParser = require('body-parser'); var http = require('http'); var ejs = require('ejs'); var app = express(); //configure the app app.set('port', process.env.PORT || 3000); // set the view engine to ejs app.set('view engine', 'ejs'); app.use(bodyParser.raw()); app.use(bodyParser.urlencoded({ extended: true })); app.use(function(req, res, next) { […]

节点zip文件夹path错误

所以我的项目结构如下所示: 根 app.js node_modules 的package.json 电子表格 我想使用zip文件夹模块压缩文件夹电子表格的内容。 提供的代码是: var zipFolder = require('zip-folder'); zipFolder('/path/to/the/folder', '/path/to/archive.zip', function(err) { if(err) { console.log('oh no!', err); } else { console.log('EXCELLENT'); } }); 我的代码是: zipFolder('./Spreadsheets/', './', function(err) { if (err) { console.log('oh no!', err); } else { console.log('EXCELLENT'); } }); 因为我想将zip保存在根文件夹中。 但是,我得到以下错误: Error: EISDIR: illegal operation on a directory, open './' […]

在nodejs中循环问题

我有一个nodejs的问题。 我试着用node-xlsx库读取一个xml文件。 libreary正确地读取文件,并在数组中添加信息。 问题是当我尝试与这个数组挂载其他数组。 码: module.exports = { getConnections: function () { var obj = xlsx.parse('xxxxx.xls'); // parses a file var connection = { customer: "", Type: "", ip: "", user: "", pass: "" } var connections = []; //loop through all rows in the sheet for (var j = 0; j < obj[0]['data'].length; j […]

如何从Ticketmaster的开放API获取所有事件数据?

我正在尝试从Ticketmaster的API获取所有事件信息,并将特定的variables添加到mongoDB中。 不过,我目前使用的APIs仅限于每页200个事件。 因此,我不可能将活动信息与场地信息联系起来,因为这些信息被单独添加到mongoDB中。 一种解决scheme可能是通过更改API-url中的页面参数来遍历所有页面,或者也可能有其他选项? 我的代码看起来像这样(抱歉的长度..): app.get('/tm', (req, res) => { axios // getting venues .get('https://app.ticketmaster.com/discovery/v2/venues.json?apikey=myApiKey&page=0&size=200&countryCode=DK') .then(response => { const venuesToBeInserted = response.data._embedded.venues.map(venue => { // preparing venues return { sourceID: venue.id, venue: venue.name, postalCode: venue.postalCode, city: venue.city.name, country: venue.country.name, countryCode: venue.country.countryCode, address: !!venue.address ? venue.address.line1 : null, longitude: !!venue.location ? venue.location.longitude : null, latitude: !!venue.location […]

如何在Node js中使用POST方法使用SOAP请求调用Web服务

var fs = require('fs'); var http = require('http'); var input = fs.readFileSync('./test.xml', { encoding: 'utf8' }); var http = require('http'); //var data = JSON.stringify( var options = { host: 'dneonline.com', port: '80', path: '/calculator.asmx', method: 'POST', headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Content-Length': input.length } }; var req = http.request(options, function(res) { var msg = ''; […]