I'm installing node.js on Ubuntu as per these instructions (
http://nodenode.com/post/1197688151/installing-node-js-on-ubuntu-screencast-tutorial )
and I'm recieving the following errors on the final step
I type node hello_node.js
my terminal replies
/home/joe/tmp/hello_node/hello_node.js:1
require(‘http’);
^
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:427:25)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
So, it seems I 'require' http. Am I doing something wrong... or worse, stupid?
You're not using normal single quotes. You have:
require(‘http’);
It should be:
require('http');
Related
I'm following the first example (copy/paste) of custom config file (lint-staged.config.js) for lint-staged packaged from its github README without success. I get error Command failed with exit code 1. always.
I tried this...
I have tried three things, for each case I had my lint-staged.config.js in the root directory.
package.json: result is error Command failed with exit code 1.
"lint-staged": {
"packages/**/*.{ts,tsx}": [
"yarn lint-staged --config ./lint-staged.config.js"
]
},
husky/pre-commit: result is error Command failed with exit code 1.
npx lint-staged --config ../lint-staged.config.js
cmd line: result is error Command failed with exit code 1.
yarn lint-staged --config lint-staged.config.js
The problem
Im just looking for run a custom config file.
The problem is that the execution fails, the error message its related to the command but the command itself its correct as lint-staged [options] (yarn/npx lint-staged -h) then to provide a custom config file it would as lint-staged [--config [path]] but it fails (I even provide all kind of quotes for path).
The issue is that when the module doesn't provide an explicit positive answer to the validation it will always return error Command failed with exit code 1 meaning that the validation has fail.
To properly work as expected it should, in my case:
first, the module had to have a return.
Secondly it should be in form of string array.
Third, the first string of the array had to be terminal-like response as '0' or 'true' of 'false'.
Then, the next following strings could be a message or messages like 'error some A' and 'error some B' and 'error some C' and so on...
For example: ['0', 'error some A', 'error some B', 'error some C']
const path = require("path");
module.exports = (absolutePaths) => {
const cwd = process.cwd();
const relativePaths = absolutePaths.map((file) => path.relative(cwd, file));
console.log("query", relativePaths)
return ['0', 'error some A', 'error some B', 'error some C']
};
This runs ok, but as Andrey Mikhaylov said in this post to run something like
"lint-staged": {
"packages/**/*.{ts,tsx}": [
"yarn lint-staged --config ./lint-staged.config.js"
]
},
If the lint returns an error, It will blow away the staged files causing a regression that will drop the commit completely, which means that all the work will be lost.
I fix this not intended/desired behaviour running the same command yarn lint-staged --config ./lint-staged.config.js but from husky at the pre-commit file as
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged --config ./lint-staged.config.js`
I use
var cmq = require('gulp-combine-media-queries')
gulp.task('cmq', function () {
gulp.src('css/style.css')
.pipe(cmq({
log: true
}))
.pipe(gulp.dest('dist'));
});
And this error is output after gulp command:
File css/style.css found.
buffer.js:169
throw new TypeError('must start with number, buffer, array or
string');
^
TypeError: must start with number, buffer, array or string
at fromObject (buffer.js:169:9)
at new Buffer (buffer.js:62:10)
at Transform.transform [as _transform] (/home/user/node_modules/gulp-
combine-media-queries/index.js:152:21)
at Transform._read (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Transform._write (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Transform.Writable.write (/home/user/node_modules/gulp-combine-
media-queries/node_modules/readable-
stream/lib/_stream_writable.js:194:11)
at write (/home/user/node_modules/vinyl-fs/node_modules/readable-
stream/lib/_stream_readable.js:623:24)
at flow (/home/user/node_modules/vinyl-fs/node_modules/readable-
stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:444:5)
at readableAddChunk (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:187:9)
Node - 4.2.6, Gulp 3.9.1, npm - 3.5.2
I also used another npms for grouping media and have the same errors. I read many articles with the same problems, but none has helped
looking at media-query code (https://github.com/konitter/gulp-combine-media-queries/blob/master/index.js)
I could see that your file "css/style.css" is not accessible by gulp hence the error.
Please recheck the path and try again
We are working on a universal app, that must execute on mobile (ios, android), desktop (windows, mac, linux) adn in any browser.
For client database management, we want to use sqlite3 - for desktop- , in this case the app will be packaged using Electron (Atom shell) . The module bundler we are using is webpack, as the app is developed with Ionic 2 and Angular2.
We have installed sqlite3 well, as a project dependency, with node-pre-gyp generating the binary for the platform (in this case we are testing with Windows 7 64 bits)
We have a provider for Sqlite3, this is the code:
import * as sqlite3 from 'sqlite3';
import { IDatabaseProvider } from './database.provider';
export class Sqlite3DatabaseProvider implements IDatabaseProvider {
private _storage;
constructor() {
console.log('Initializing Sqlite3 Database Provider');
}
openDatabase() {
this._storage = new sqlite3.Database('v2App_sqlite3.db');
}
}
As you can notice, the line the creates a database is commented, as the app works OK like that. If I uncomment that line , we have this error:
Runtime Error
Cannot read property '_handle' of undefined
TypeError: Cannot read property '_handle' of undefined
at http://localhost:8100/build/main.js:210758:15
at Array.forEach (native)
at module.exports (http://localhost:8100/build/main.js:210757:36)
at Object.<anonymous> (http://localhost:8100/build/main.js:12580:1)
at Object.<anonymous> (http://localhost:8100/build/main.js:12873:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:69457:11)
at Object.<anonymous> (http://localhost:8100/build/main.js:69638:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:211548:72)
The curious of this, is that it's failing here, in the code of the set-blocking npm module:
module.exports = function (blocking) {
[process.stdout, process.stderr].forEach(function (stream) {
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(blocking)
}
})
}
As stream is coming undefined ,when getting the _handle property gives the error.
But this code is only executed if I add the line that creates the sqlite3 database:
this._storage = new sqlite3.Database('v2App_sqlite3.db');
What is the relation between this module (set-blocking ) and sqlite3 ?, Why the streams are undefined when trying to create the sqlite3 database ?
Maybe as generates a file - the database - , using Node's outputStream, and still could not have been created that object - stream.
Any help?
Thanks in advance
Here is bonescript for testing serial connection in BeagleBone black by exchanging and incrementing characters
var b = require('bonescript');
var port1='/dev/ttyO1';
var port2='/dev/ttyO2';
var options={
baudrate: 9600,
parity: 'even',
parser: b.serialParsers.readline("\n")
};
console.log(b.serialOpen(port1, options, onSerial1));// open port 1
console.log(b.serialOpen(port2, options, onSerial2));//open port 2
b.serialWrite(port1,'A');//start letter bouncing
function onSerial1(x){
if (x.event == 'data') {
console.log(x.data);
var char =x.data;//get letter
if(char=='Z')
char='A';// reset or incremet
else
char++;
b.serialWrite(port2,char);
}
}
function onSerial2(x){
if (x.event == 'data') {
console.log(x.data);
var char =x.data;
if(char=='Z')
char='A';
else
char+=1;
b.serialWrite(port1,char);
}
}
Here is output in cloud9:
^
debugger listening on port 15454
true
true
events.js:72
throw er; // Unhandled 'error' event
^
Error: Serialport not open.
at SerialPort.write (/usr/local/lib/node_modules/bonescript/node_modules/serialport/serialport.js:246:17)
at Object.exports.wrapCall.newFunction [as serialWrite] (/usr/local/lib/node_modules/bonescript/my.js:198:41)
at Object.<anonymous> (/var/lib/cloud9/serial/myserial.js:12:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain [as _onTimeout] (module.js:497:10)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
As you may see serialOpen successfully opens the ports (returns true) but initial write fails. I can.t think of a reason.
It is possible that port2 is not yet opened when port1 sends it the letter A at the first time.
Try to make some delay between the 2 lines
console.log(b.serialOpen(port2, options, onSerial2));//open port 2
b.serialWrite(port1,'A');//start letter bouncing
You may try using setTimeOut(b.serialWrite(port1,'A'), 2000);
or write on port1 when the event at port2 is opened.
I'm getting following exception thrown:
=> Meteor server restarted
I20130820-00:17:58.852(3)? Exception from setTimeout callback: { stack: [Getter] } MongoError: $or requires nonempty array
I20130820-00:17:58.852(3)? at Object.Future.wait (/home/alexei/.meteor/tools/4010e5731d/lib/node_modules/fibers/future.js:326:15)
I20130820-00:17:58.853(3)? at _.extend._nextObject (packages/mongo-livedata/mongo_driver.js:540)
I20130820-00:17:58.853(3)? at _.extend.forEach (packages/mongo-livedata/mongo_driver.js:570)
I20130820-00:17:58.853(3)? at _.extend.map (packages/mongo-livedata/mongo_driver.js:582)
I20130820-00:17:58.853(3)? at _.extend.fetch (packages/mongo-livedata/mongo_driver.js:606)
I20130820-00:17:58.853(3)? at _.each.Cursor.(anonymous function) [as fetch] (packages/mongo-livedata/mongo_driver.js:444)
I20130820-00:17:58.854(3)? at MongoConnection.findOne (packages/mongo-livedata/mongo_driver.js:362)
I20130820-00:17:58.854(3)? at _.extend.findOne (packages/mongo-livedata/collection.js:225)
I20130820-00:17:58.854(3)? at _.extend.findOne (packages/collectionFS/collectionFS_common.js:4)
I20130820-00:17:58.855(3)? at _.extend.checkQueue (packages/collectionFS/collectionFS_filehandlers.js:95)
I20130820-00:17:58.855(3)? - - - - -
I20130820-00:17:58.855(3)? at Object.toError (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/utils.js:110:11)
I20130820-00:17:58.855(3)? at Cursor.nextObject.self.queryRun (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/cursor.js:634:54)
I20130820-00:17:58.856(3)? at Cursor.close (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/cursor.js:903:5)
I20130820-00:17:58.856(3)? at Cursor.nextObject.commandHandler (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/cursor.js:634:21)
I20130820-00:17:58.856(3)? at Db._executeQueryCommand (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/db.js:1658:9)
I20130820-00:17:58.856(3)? at Server.Base._callHandler (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/connection/base.js:378:41)
I20130820-00:17:58.856(3)? at Server.connect.connectionPool.on.server._serverState (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/connection/server.js:468:18)
I20130820-00:17:58.857(3)? at MongoReply.parseBody (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
I20130820-00:17:58.857(3)? at Server.connect.connectionPool.on.server._serverState (/home/alexei/.meteor/packages/mongo-livedata/86ae77f282/npm/node_modules/mongodb/lib/mongodb/connection/server.js:426:20)
I20130820-00:17:58.857(3)? at EventEmitter.emit (events.js:96:17)
Please advise, what is causing the problem?
I'm on 0.6.5 meteor, 0.6.6 mrt, 0.10.13 node and 1.3.2 npm.
BTW, application itself works fine :)
Please advise.
Thank you,
Alexei
The query inside your Meteor.setTimeout block of code has an $or keyword which contains an empty array. You need to have at least two items in there for your operation.
If you're having trouble/using some kind of way to build an $or query you could update your code with this block of code so we could be of further help