I'm using mocha for unit tests and trying to use jsdom for html elements on my unit tests.
I downloaded the jsdom.zip and imported the library for my tests, and get stuck on this error:
jsdom/living/attributes.js:114
for (const name of Object.getOwnPropertyNames(prototype)) {
^^ SyntaxError: Unexpected identifier
I tried to find the cause of this error message on Google but unfortunately I wasn't able to find an answer.
The latest JSDOM does not work with older versions of Node (the syntax error is probably the ES6 const). As the readme says:
Note that as of our 4.0.0 release, jsdom no longer works with
Node.js™, and instead requires io.js. You are still welcome to install
a release in the 3.x series if you use Node.js™.
Try upgrading to latest Node or downloading version 3.x (also, NPM might make this much easier than downloading ZIP files :)
Related
I have an angular application I haven't touched in a while. I haven't made any changes since the last time it was working. Now I need to modify a few things. But the application won't serve locally so I can't make the changes. I don't understand what's wrong.
The npm install worked just fine and I don't have any code errors preventing it from running. I get the following error message when trying ng serve, but it seem extremely unhelpful. Any ideas?
Unfortunately without an exact reproduction of your project this will be really hard to pin point, but looking at what is given in the screen shot and prior experience with similar issues, I think this could be an issue with your package.json. Newer versions of node and npm look for the carets symbol (^) in both your package.json and the installed modules' package.json. When found, it will install newer versions of the package without error. Then when you go to run the project, the typings will break and Angular will refuse to compile and you get errors like these.
I would recommend removing all carets in older Angular projects to prevent this from happening as it is common occurence even when upgrading from more modern versions (I had this happen to me when upgrading from Angular 13 to Angular 14). However, with Angular 1.7/AngularJS not being supported anymore, I would recommend that you look into upgrading or rewriting the project in a modern version of Angular or another modern framework that fits the projects needs.
I'm customizing ckeditor5, It can build successfully but when implemented it has an error saying "CKEditorError: ckeditor-duplicated-modules". I'm not sure what module duplicated.
In my code imported
Try to install the same version plugins (it work for me) likes:
check ckeditor5-core version fisrt
#ckeditor/ckeditor5-core": "^33.0.0"
I want to add "table" tool, use
npm i #ckeditor/ckeditor5-table#33.0.0"
to get specified version, instead of
npm i #ckeditor/ckeditor5-table
you may get a newer version, which need the second ckeditor5-core package lead to duplicated-modules (now you know which module duplicated)
I want to start coding with Tabris.js, and try to get some experience with the playground. But every example which uses
async function asyncFunctionName(...)
doesn't start. The error message is:
Could not load main module: Error: Could not parse ./app.js:./app.js:7:
SyntaxError: Unexpected token function
async function showActionSheet() {
^^^^^^^^
com.eclipsesource.v8.V8ScriptCompilationException
at subscribe (./cordova.js:758:11)
at addEventListener (./cordova.js:133:34)
at _entryPoint (./cordova.js:1560:18)
The simple examples like hello.js work well. The shipped examples in the tabris developer app work well.
What am I doing wrong?
Comparing the output of what the Playground generates to what's inside the app they are definitely different. Tabris.js on Android does not yet support the async/await syntax natively (but iOS does).
This looks like a bug in implementation of the Playground, so it'd be worthwhile to open an issue for that. In the meantime, you can also clone the repo and run the snippets using the instructions included in the snippets directory:
npm install -g tabris-cli
git clone https://github.com/eclipsesource/tabris-js
cd tabris-js/snippets
tabris serve -m dist/actionsheet.jsx
The Wekan code that be built by Meteor cannot run in node 0.10.4x ,
Meteor will create the code for new version node, like const or lambda expression.
How to ask Meteor to build the code that can be run in node 0.10.4x ?
Error 1:
/home/wekan/output/bundle/programs/server/packages/modules.js:33433
const Boom = require(‘boom’);
^^^^^
SyntaxError: Use of const in strict mode.
at /home/wekan/output/bundle/programs/server/boot.js:292:30
at Array.forEach (native)
at Function..each..forEach (/home/wekan/output/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
at /home/wekan/output/bundle/programs/server/boot.js:133:
Error 2:
/home/wekan/output/bundle/programs/server/packages/modules.js:33571
credentialsFunc(attributes.id, (err, credentials) => {
^Preformatted text
SyntaxError: Unexpected token >
at /home/wekan/output/bundle/programs/server/boot.js:292:30
at Array.forEach (native)
at Function..each..forEach (/home/wekan/output/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
at /home/wekan/output/bundle/programs/server/boot.js:133:5
According to the Wekan documentation at https://github.com/wekan/wekan/wiki/Install-and-Update
If you haven't already, you need to install Node.js, given that we
need node version 4.8.4, make sure to either use the custom packages
(the ones of your OS are likely too old) or install the correct
version from the Node.js website.
Node 0.10.4 is pretty old already, I don't know why you are still using it. You can use something like nvm if you want to manage different versions of node on your machine.
It seems, you're using really old version of wekan that needs such old version of node.
Unfortunately, babel transpiler (Meteor is using it to transpile JS code) has dropped support for Node 0.10 and 0.12 (discussed here).
I'd suggest you to update your wekan version or use nvm to install and use different version of node simultaneously.
I'm trying to run node.js backend server. I've received error unexpected reserved word on import in Node.js file.
The lines in file core.module.js is:
'use strict';
import lodashMixins from './lodashMixins.js'
... other imports and configurations ...
I launch simple command: node core.module.js
It's not uncommon error, but usually it happens with other libraries. I haven't seen solution for Node.js. How should I fix this? I'm using Windows Server.
Edit: I've find out that it's ES6, but how could I launch it? It looks like backend for the application, but I have no idea what command should I use to launch it without errors.
import is a part of ECMAScript 2015 (ES6) standard and as Amit above mentioned it is not currently implemented natively in Nodejs.
So you can use transpiler like babel to run your es6 script
npm install babel
An example based on this answer
app.js
import {helloworld,printName} from './es6'
helloworld();
printName("John");
es6.js
module.exports = {
helloworld: function() { console.log('hello world!'); },
printName: function(name) { console.log(name); }
}
And using require hook in start.js
require("babel/register");
var app = require("./app.js");
And start your app as
node start.js
EDIT
The above answer was base on babel v5.8.23. For babel >= v6
Use require hook in start.js as
require('babel-core/register');
require("./app.js");
Also, transformations are not enabled by default. So you will need to install a preset. In this case use es2015
npm install babel-preset-es2015
And use it in a .babelrc file in root folder
{
"presets": ["es2015"]
}
The import keyword is part of the modules feature in ECMAScript 2015, along with export and a few other specifications.
It is currently not implemented natively in NodeJS, even on the lastest version (v0.12.7), nor is it supported in the ES2015 "friendlier" fork iojs.
You will need to use a transpiler to get that to work.
[edit] it's still unsupported in the latest version (v5.8) despite the existence of an --harmony_modules flag, which does nothing. Your best run is to use babel, as explained here and here
I ran into this issue as I manually install any of these tools outside of Visual Studio. But Visual Studio ships with multiple open source command line tools that are used in modern web development workflows. Here’s how you can tell Visual Studio to use the same version that you have manually installed
Go to Tools –> Options –> Projects and Solutions –> External Web Tools
Set the global PATH environment variable before the internal path, you can just use the arrows at the top-right to change the order.
or
First, find the Node.js installation you already have and use at the command line. By default, Node.js 0.12.7 installs to “C:\Program Files\nodejs”. Add this entry at the top to the path to the node.js directory to force Visual Studio to use that version instead
This may not be the official answer, but I stumbled here after searching around for the 'unexpected reserved word'. After poking around, I discovered my problem was that, in fact, I just needed to run an npm install after having updated my branch from origin / rebasing. Hope this helps someone else who is furiously reverting their code trying to figure out what they broke! :)