0

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
user3700562
  • 693
  • 11
  • 23
  • Does this answer your question? [ReferenceError: globalThis is not defined](https://stackoverflow.com/questions/66586352/referenceerror-globalthis-is-not-defined) – RobC Mar 20 '21 at 16:28
  • You say _"I would rather not install a different version of node or npm"_ and _"I'm afraid it will break other projects otherwise"_, in which case consider [using a Node version manager to install Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm) - this will enable you to have different versions of node.js/npm installed and switch to specific versions for specific projects. – RobC Mar 20 '21 at 16:45
  • Thanks, I will give that a shot – user3700562 Mar 20 '21 at 16:56

2 Answers2

0

Just make sure to reinstall the cordova if your node version changed. And after that, cordova prepare again.

zhangv
  • 950
  • 1
  • 9
  • 25
0

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