I am following Cordova's Getting Started guide but I'm already stuck at the 2nd step. When I try to create my project by typing cordova create myApp, it fails with the following error message:
C:\Users\foobar\AppData\Roaming\npm\node_modules\cordova\node_modules\queue-microta
sk\index.js:5
? queueMicrotask.bind(globalThis)
^
ReferenceError: globalThis is not defined
at Object.<anonymous> (C:\Users\foobar\AppData\Roaming\npm\node_modules\cordova
\node_modules\queue-microtask\index.js:5:25)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (C:\Users\foobar\AppData\Roaming\npm\node_modules\cordova
\node_modules\run-parallel\index.js:4:24)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
I guess it's some sort of node or npm version problem. If possible though, I would rather not install a different version of node or npm, because I'm afraid it will break other projects otherwise. My node and npm versions are as follows:
node --version
v11.15.0
npm --version
6.7.0
Just make sure to reinstall the cordova if your node version changed.
And after that, cordova prepare again.
change Node version with Node Version Manager (NVM) to Node version10.X.X.
queueMicrotask don't work with Node version 11.X.X.
https://github.com/feross/queue-microtask/issues/13
Related
Whenever I try to run nodemon to auto-restart my local server (running on port 3000), I get this error message regarding a syntax error in the no
/Users/SI23/.nvm/versions/node/v6.5.0/lib/node_modules/nodemon/node_modules/chokidar/index.js:151
async remove(item) {
^^^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/SI23/.nvm/versions/node/v6.5.0/lib/node_modules/nodemon/lib/monitor/watch.js:6:16)
at Module._compile (module.js:556:32)
Any way to fix this?
As per my knowledge
Async Await is not available in node v6.5.0,
which you are using. So you can upgrade your node version or can start using Promise object with the same version of node.
In my case, npm list chokidar helped me realize it was another module (gulp-nodemon) that used a newer version of chokidar. It worked after downgrading it.
I had exactly the same error...! it was a node version problem, I was on node version 6, this is what I did to fix it:
nvm install <VERSION_NUMBER> // nvm install 10.15.3
nvm use <VERSION_NUMBER> // nvm use 10.15.3
node -v // confirm i am using the correct version of node
Remember to do this on your computer not just your code file and change the default node version with nvm alias default 10.15.3
you can check your default lists with
nvm list
I need to work with an app based on ionic framework v1 and Cordova 7.1, but there is the following problem with Node when running Cordova:
$ cordova -v
/node_modules/cordova/node_modules/npm-normalize-package-bin/index.js:3
const {join, basename} = require('path')
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (node_modules/cordova/node_modules/read-package-json/read-json.js:14:27)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
I installed Cordova with this command:
npm install -g cordova#7.1.0
The project requires the following versions which are installed on my machine:
node -v
v5.12.0
npm -v
3.8.6
ionic -v
1.7.15
grunt --version
grunt-cli v0.1.13
grunt v0.4.5
bower -v
1.8.4
plugman -v
2.0.0
Does anyone have a clue where the problem is? I'm glad for any help.
The problem is that nodejs v5.x doesn't support destructuring, which is used in the line
const {join, basename} = require('path')
You can read more about supported js features in nodejs here, https://node.green/#ES2015-syntax-destructuring--declarations
Cordova depends on "init-package-json" which in turn depends on "read-package-json: 1 || 2".
Now there's been an update to "read-package-json" some months ago which introduces a new dependency to "npm-normalize-package-bin". This package makes use of a syntax construct that's apparently supported not before node 6.0.0.
So, if updating node is not an option (which is recommended, since node 5 - 8 is end-of-life), you may install this (also rather outdated) cordova locally (inside the project folder) and overwrite the read-package-json dependency there by npm i read-package-json#2.0.13.
Edit: Call cordova via npx: npx cordova -v
Thank you all for your helpful inputs to better understand the cause.
Unfortunately, updating node was not an option. In the end, I compared my Cordova installation with a teammate who does not have this problem. The only difference was that his 'cordova/node_modules/npm-normalize-package-bin' was not present where the error is triggered. So I deleted this package from my system to solve the problem.
Maybe this will help somebody else.
It has been a long time since I programmed using my personal computer. I usually use a work computer. However, yesterday I decided to start working on a new pet project. Well, I went to set up the website in my Vagrant using VirtualBox, and now nvm, npm, and node are all messed up.
Every time I try to run npm install to set-up the node_module in my project, I get this error:
/home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/lib/utils/unsupported.js:27
console.error(`a bug known to break npm. Please update to at least ${r
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
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.require (module.js:364:17)
at require (module.js:380:17)
at /home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
No matter what I try to do in npm (upgrade it, install, delete, uninstall, etc) it just throws this error.
Could somebody please help me?
The version of npm you have is not supported on Node v0.10.32. In fact Node v0.10 itself is not supported either and projects are actively dropping support it. Most dependencies will want node v4+ these days.
The version of npm you have installed will be available in the VM:
cat /home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/package.json
You will need to manually extract one of the v2 or possibly even a v1 npm release over the files in /home/vagrant/.nvm/v0.10.32/lib/node_modules/npm.
Removing and setting up your nvm v0.10.32 environment again should also take npm back to a working release.
I would guess your Vagrant build does something like an npm install -g npm which would have worked at some stage but now installs the latest, incompatible version.
Use npm install -g npm#2 to stick to a v2.x release
I get the following error when trying to start my server.js which requires the module "userid".
module.js:460
return process.dlopen(module, path._makeLong(filename));
^
Error: Module version mismatch. Expected 46, got 47.
at Error (native)
at Object.Module._extensions..node (module.js:460:18)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/root/backend/node_modules/userid/lib/userid.js:2:15)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
How can I solve this issue?
Not sure of the exact meaning of this error but my fix for this is to delete the node_modules directory and reinstall the required modules with npm install.
The above is a solution for this error showing up in a node project which uses locally installed modules. If there are some global modules that are throwing this error then you might have to reinstall those.
I would try upgrading the module version that causes the issue on package.json.
Another reason of this problem is that you have several different node versions installed at your system and you manage them with nvm. If you run node index.js and if you run sudo node index.js it may results in running different node version.
So if you installed your application modules with npm install and then run application with sudo node index.js you will have Module version mismatch error. In such case make sure with nvm that sudo node... run the same version of node as your application expects.
Also, while fixing initial problem you may have problem with nvm described here Can't use NVM from root (or sudo). One of possible solutions to this issue described in Yoo Matsuo's comment.
I'm trying to install Ionic on Ubuntu 12.04, but I get this error message:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object #<Object> has no method 'tmpDir'
at /usr/local/lib/node_modules/npm/node_modules/osenv/osenv.js:49:13
at Object.tmpdir (/usr/local/lib/node_modules/npm/node_modules/osenv/osenv.js:14:15)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/defaults.js:76:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:4:18)
My node version is v0.6.12.
Could you please update the node to latest version. 0.6.12 is way behind the current node version, also see what version of node js ionic supports.
Current NodeJS Version is 0.12.2
Turns out the problem was related to npm and not nodejs. After checking what Sathish suggested, I realized that I couldn't use npm not even to check its version. I removed both nodejs and npm and I followed this tutorial and everything works fine. Thanks to everybody!