How can I run script files by their shortcuts in Windows? - windows

Tried naive way with a standard Windows shortcut file and with a cmd.exe, failed like this:
D:\...>node tty-checker.js.lnk
D:\...\tty-checker.js.lnk:1
(function (exports, require, module, __filename, __dirname) { L
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Maybe you can suggest a way?
Amazing if there is a general method working not only for .js, but for any other source code file type too.

Related

How to fix Unexpected token { when running npx cypress?

I run
npx cypress
And get
Unexpected token {
Maybe there is a way to get more details, tried:
DEBUG=cypress:server:socket-base npx cypress
But still same error and no more info. First it was working, I think I did not change anything and one day it started giving this error. Maybe I changed something not knowing that I did.
Maybe it has to do something with versions?
npx -v
6.14.5
Update:
Executed different way
$ ./node_modules/.bin/cypress
/home/darius/Private/Projects/vop-live-automated-checks/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/home/darius/Private/Projects/vop-live-automated-checks/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
Maybe this is same but full error?
If it suddenly happened, you might have switched out of bash terminal. double check.
Just deleted node_modules and ran
npm install
and now works.

Rxjs Mocha tests will not run on WebStorm

I have been trying to get the spec tests running from the rxjs repository on the WebStorm IDE.
https://github.com/ReactiveX/rxjs.git
The issue is that I can run the tests using the included script, and manually through the command line but configuring WebStorm is not working.
Below is the error message that I am getting most frequently. I have included the default opts file for Mocha, and below is the result.
ReferenceError: asDiagram is not defined
at Suite.<anonymous> (/Users/test/Desktop/Test/rxjs/spec/Observable-spec.ts:636:3)
at Object.create (/Users/test/Desktop/Test/rxjs/node_modules/mocha/lib/interfaces/common.js:112:19)
at context.describe.context.context (/Users/test/Desktop/Test/rxjs/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Object.<anonymous> (/Users/test/Desktop/Test/rxjs/spec/Observable-spec.ts:635:1)
at Module._compile (module.js:652:30)
at Module.m._compile (/Users/test/Desktop/Test/rxjs/node_modules/ts-node/src/index.ts:430:23)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .ts] (/Users/test/Desktop/Test/rxjs/node_modules/ts-node/src/index.ts:433:12)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
the problem occurs because Webstorm is passing --ui bdd to mocha, overwriting your custom ui specified in spec/support/default.opts. To work out the issue, you have to change User interface: option in Mocha run configuration from default (bdd) to your custom one (spec/helpers/testScheduler-ui.ts) - field is editable, you can type/paste the value. Configuration that works fine for me:

SyntaxError: Unexpected token =>

When I ran the gulp command from the root of the project, a problem turned out.
elixir((mix) => {
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at execute (D:\nodejs\node_global\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:24:18)
at Liftoff.handleArguments (D:\nodejs\node_global\node_modules\gulp-cli\index.js:149:63)
at Liftoff.<anonymous> (D:\nodejs\node_global\node_modules\gulp-cli\node_modules\liftoff\index.js:198:16)
The gulpfile is from a Laravel Project, here it is https://github.com/rappasoft/laravel-5-boilerplate/blob/master/gulpfile.js .
I had searched the problem above over stack and other network station, but couldn't find any useful advise.
Btw, it was run on Windows, you can get it from the details code above.
If somebody can help, I will be very appreciate . THX !
Arrow function are new JavaScript (ES6), so maybe your node and npm version is old and you should upgrade it. Use this official installer.
https://nodejs.org/dist/v6.9.2/node-v6.9.2-x64.msi

Error "Cannot find module 'errors.server.controller.js'" while trying to extend default backend

I want to add new code to my backend, which will put some data to MongoDB collection. I decided to do it in core.server.controller.js because my app will be really simple and I don't need to create a new module for this. So I opened /app/controllers/users/users.profile.server.controller.js, a mean.js built-in controller and copied
var _ = require('lodash'),
errorHandler = require('../errors.server.controller.js'),
mongoose = require('mongoose'),
passport = require('passport'),
User = mongoose.model('User');
to core.server.controller.js file to provide mongoose and the other stuff. Then I removed ../ from errorHandler require argument and changed mongoose model name to my own, which I've created before.
But when I want to start this app in console, I get an error:
Error: Cannot find module 'errors.server.controller.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/developer2/baca/app/controllers/core.server.controller.js:7:17)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at module.exports (/Users/developer2/baca/app/routes/core.server.routes.js:5:13)
at /Users/developer2/baca/config/express.js:118:35
at Array.forEach (native)
at module.exports (/Users/developer2/baca/config/express.js:117:49)
at Object.<anonymous> (/Users/developer2/baca/server.js:24:38)
So how can I fix this?
You are requiring errors.server.controller.js however the path is wrong.
You can either use the file path relative to your app root directory or to the file (core.server.controller.js) from where you're requiring:
Solution 1: Path relative to the app root directory (preferred for the sake of consistency since MEAN.js uses path for requires in other js files):
You can use node path module to help you with this like so:
var path = require('path),
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller.js'));
Note that the file path is relative to the root directory of your app and path module will handle that for you.
Solution 2: Path relative to the current file:
Since they are both in the same directory:
var errorHandler = require('./errors.server.controller.js');

Can't run Google Coder on Mac

I'm trying to run Google Coder on Mac following the following instructions:
http://pi.gadgetoid.com/article/running-google-coder-on-your-existing-raspberry-pi-or-desktop-pc
Everything goes well until I have to launch the server. This is what I get:
node server.js
module.js:340
throw err;
^
Error: Cannot find module '/Users/sebasribas/Downloads/coder-master/coder-base/apps/auth/app'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at pingStatusServer (/Users/sebasribas/Downloads/coder-master/coder-base/server.js:187:23)
at Object.<anonymous> (/Users/sebasribas/Downloads/coder-master/coder-base/server.js:278:1)
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)
Any suggestion?
Thanks a lot for your help.
Found this here: https://github.com/googlecreativelab/coder/issues/56
You'll need to install the relevant apps before it'll work.
cd ~/coder-dist/coder-apps/
Install the base apps that are common to all platforms:
./install_common.sh ../coder-base/
This copies the common platform apps to the coder-base working directory.
By looking at your error log you're missing a module. Did you run 'npm install' in the coder-base directory after downloading it?
A little tedious, I'm sure there's a more automated way, but...
Follow the robot instructions in coder-apps/install_app.sh
Basically, you copy the app directories from coder-apps/common into three places:
coder-base/apps
coder-base/static
coder-base/views
So that in each of these directories there is a folder per-app.
Then, copy the contents of those app's respective 'app', 'static', and 'views' folders into the root of the application directory.
For example- in coder-base/apps, for the "auth" app, I copied /app/app.js and /app/meta.json into the root level of the directory that I just created: coder-base/apps/auth.
You don't have to copy all the sample apps, but you definitely need at least the auth, editor, boilerplate, and coderlib.
I'd just copy them all to be safe!
Have fun hacking :)

Resources