I want to reqiure my html but I can not do it. My code is so simple :
module.exports = {
html: require('./template.html')
};
When I run codes, It gives this error:
SyntaxError: Unexpected token <
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 Module.require (module.js:366:17)
require (module.js:385:17)
at Object.<anonymous> (D:\frontend\lokidump\server\views\traders\betofcourse\upcomingEvents\index.js:2:9)
When you use require on a file it is expecting a JavaScript file, not an HTML file. If you want to load the contents of the HTML file into a variable look into fs.readFile
Related
when I try to start app "sudo start app.js", it throws exception
const {notFoundRouteError} = require('../errors');
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/project-path/server/index.js:4:25)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
Also downgraded node version to v6.11.0 but it still doesn't work
Also try let instead of const like this,
But, you need to enforce the strict mode.
"use strict"
let {notFoundRouteError} = require('../errors');
Hope this helps!
I have a declaration of a variable in my spec file(app.Login.ts), lets say
[Let comment = 'hello']
and now this variable (comment), i need to use in my protractor.config.js file. When I'm trying
using import { comment } from './e2e/app.Login';
i'm getting error saying
import { comment } from './e2e/app.Login';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
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)
at require (internal/module.js:11:18)
at ConfigParser.addFileConfig (C:\Users\M220101\AppData\Roaming\npm\node_modules\protractor\built\configParser.js:135:26)
How to resolve it?
I'm a novice attempting to write my 1st hyperledger app.
I am following the instructions at https://hyperledger-fabric.readthedocs.io/en/release-1.2/write_first_app.html.
all appears to be working fine until I get to this:
$ node enrollAdmin.js:
/home/mark/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:230
getChannel(name, throwError = true) {
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/mark/fabric-samples/fabcar/node_modules/fabric-client/index.js:25:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
Exception occurred while trying to require Ajv module.
var Ajv = require('C:/../node_modules/ajv/lib/ajv.js')
Exception occurred in vm.js at
function createScript(code, options) {
return new Script(code, options);
}
Exception has occurred: SyntaxError
SyntaxError: Unexpected token new
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\myFile.js:1:73)
Any suggestions to correct this?
It might sound really funny but I had to uninstall and install back ajv.js to get this working.
Any clues about what could have happened?
I know this is obvious. I just can't see it.
This is part of a node/express app..
'use strict';
var express = require('express');
var controller = require('./iresize.controller');
var router = express.Router();
router.post('/', controller.send);
module.exports = router;
Which leads to..
SyntaxError: missing ) after argument list
at (/Code/server/iresize/index.js:4:18)
i.e. var controller = require('./iresize.controller');
I don't get it. I have lots of other routes and controllers that look exactly the same. I'm not sure why this one isn't working..
Note: I have cut down the error output for clarity. There is routes.js calling it like so...
app.use('/r', require('./iresize'));
and then in iresize dir I have index.js and resize.controller files..
The full error output is as so:
node server/app.js
[Error: Module version mismatch. Expected 46, got 14.]
js-bson: Failed to load c++ bson extension, using pure JS version
SyntaxError: missing ) after argument list
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function._load (/Code/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Code/server/iresize/index.js:4:18)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function._load (/Code/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:365:17)
at require (module.js:384:17)
NB: One of the Exceptions is at this file. However if I remove the app.use.. line above everything works fine.