VUE3: npm init throws error unexpected token - node.js

just started with the new Vue3 initialization (npm init vue#latest) and right out of the gate i get an error:
npx: installed 1 in 1.787s
C:\neard\tmp\npm-cache\_npx\10696\node_modules\create-vue\outfile.cjs:3896
const isFeatureFlagsUsed = typeof (argv.default ?? argv.ts ?? argv.jsx ?? argv.router ?? argv.pinia ?? argv.tests ?? argv.vitest ?? argv.cypress ?? argv.playwright ?? argv.eslint) === "boolean";
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:1063:16)
at Module._compile (internal/modules/cjs/loader.js:1111:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
have no idea where to begin troubleshooting this. brand new NodeJS install. you'll see from the path that i'm running neard as my stack BUT i do not have NodeJS running on it; i have it installed in the base machine. in fact i'm not running neard at all right now, it's just where i have all my projects.
anyway. any suggestions would be helpful. i've tried searching for a similar problem, but found nothing.

From what you have provided it looks like there may be an issue with the version of Node.js you are using. The code you posted includes syntax that uses the "nullish coalescing operator" (??), which was introduced in Node.js 14.
Do
node -v
As this shouldn't be happening on the new build of node.js
So I recommend that you update to the latest node.js build: 19.2.0 as this should fix the current problem you are having.

Related

Error while trying to deploy page - npm errors

I am trying to deploy my github page on Cloudfare and I am getting a bunch of errors. I tried installing lating versions od npm and node.js but I really dont understand what I need to do to fix them. Also, looked in my package.json file and I dont have a script for a build. Do I add one, and if so, what do I add to the scripts section? Here is the error message:
ERROR: npm v9.4.2 is known not to run on Node.js v12.18.0. You'll need to upgrade
07:11:10.568 to a newer Node.js version in order to use this version of npm. This version of
07:11:10.569 npm supports the following node versions: ^14.17.0 || ^16.13.0 || >=18.0.0. You
07:11:10.569 can find the latest version at https://nodejs.org/.
07:11:10.569
07:11:10.569 ERROR:
07:11:10.569 /opt/buildhome/repo/node_modules/npm/lib/utils/exit-handler.js:21
07:11:10.570 const hasLoadedNpm = npm?.config.loaded
07:11:10.570 ^
07:11:10.570
07:11:10.570 SyntaxError: Unexpected token '.'
07:11:10.570 at wrapSafe (internal/modules/cjs/loader.js:1054:16)
07:11:10.570 at Module._compile (internal/modules/cjs/loader.js:1102:27)
07:11:10.570 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
07:11:10.570 at Module.load (internal/modules/cjs/loader.js:986:32)
07:11:10.570 at Function.Module._load (internal/modules/cjs/loader.js:879:14)
07:11:10.571 at Module.require (internal/modules/cjs/loader.js:1026:19)
07:11:10.571 at require (internal/modules/cjs/helpers.js:72:18)
07:11:10.571 at module.exports (/opt/buildhome/repo/node_modules/npm/lib/cli.js:81:23)
07:11:10.571 at Object. (/opt/buildhome/repo/node_modules/npm/bin/npm-cli.js:2:25)
07:11:10.571 at Module._compile (internal/modules/cjs/loader.js:1138:30)
07:11:10.577 Failed: build command exited with code: 1
07:11:11.469 Failed: an internal error occurred
I tried installing latest versions of npm and node.js and waas expecting it to be updated but i am getting the same error.

Testcafe / Jenkins job failing TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function. Received undefined

I have a jenkins job that has worked consistently for the past 2 years running various front end tests, but recently I've gotten a stack trace from the job in jenkins that is continuously failing where I'm unsure what to do to fix it. The stack trace is listed below from the job:
TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function. Received undefined
at promisify (internal/util.js:279:11)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe-safe-storage/lib/file.js:18:33)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe-safe-storage/lib/index.js:30:19)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe/lib/dashboard/config-storage.js:3:33) {
code: 'ERR_INVALID_ARG_TYPE'
}
I am facing the same issue. Looks like there was a latest version of testCafe 1.19.0 version released yesterday after which the issue started. If you change your testcafe version to "testcafe": "1.18.6" or remove the ^ it should work. Or may be need to upgrade the nodejs version being used. Got the below warning
npm WARN notsup Unsupported engine for testcafe#1.19.0: wanted: {"node":">=14.0.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
This is due to the testcafe global version. I think
you can check the global version by testcafe --version
and confirm your project installed version -> you can check your package.json file
If both are mismatch means, this issue could occur. So you should set BOTH version to be same
Ex: npm i -g testcafe#1.18.6
In package.json --> testcafe": "^1.18.6
in my case, its works perfectly. and also I have used firefox:headless
The cause of the issue is that you are using an outdated Node.js version.
The crypto.randomUUID function doesn't exist in Node.js 10.24.1.
Please update it to 14.x and all will work correctly.

Cannot import cloudinary in nodeJS with "navigator undefined" error

I recently installed cloudinary via npm and cannot import it in my nodeJS backend due to the following error.
(base) feiwu#Feis-MacBook-Pro backend % node server.js
/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168
var useAgent = navigator && navigator.userAgent || '';
^
ReferenceError: navigator is not defined
at Module../src/namespace/cloudinary-core.js (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168:16)
at __webpack_require__ (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:37:30)
at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:101:18
at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:104:10
at webpackUniversalModuleDefinition (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:10:20)
at Object.<anonymous> (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:17:3)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary/lib/utils/index.js:48:57)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
I have found nothing so far about this error and would like to know if someone know about this issue ?
This error is from cloudinary's end. Fix this error with npm i cloudinary-core.
Started happening to me around 15 hours ago as well.
Cloudinary had just released a new version to its JS SDK (version 2.12.2) that fixes this issue.
installing cloudinary-core helped me get rid of this error
npm i cloudinary-core
This issue was introduced recently in Cloudinary version 1.28.0.
https://www.npmjs.com/package/cloudinary/v/1.28.0
The issue reported on github here : https://github.com/cloudinary/cloudinary_npm/issues/524
I was able to fix this issue by pointing cloudinary to 1.27.1
"cloudinary": "1.27.1"
Cloudinary guys have fixed this issue here : https://github.com/cloudinary/cloudinary_js/pull/281.

Primordials is not defined

I'm trying to execute this code but I don't know why it shows error. I'm new at Nodejs, so i attach the code and ss of error please help how to fix this
var webshot = require('webshot');
var flatiron = require('flatiron');
var app = flatiron.app;
app.use(flatiron.plugins.http);
app.router.get('/getImage', function() {
var self = this;
var requestUrl = this.req.headers['head'];
console.log(requestUrl);
webshot(requestUrl, function(err, renderStream) {
renderStream.pipe(self.res);
});
});
app.start(3000,"IP Address");
console.log('Starting Node Server');
error =
Debugger attached.
Waiting for the debugger to disconnect...
fs.js:45
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:45:5
at req_ (c:\Users\HOME\Desktop\NodeScripts\node_modules\natives\index.js:143:24)
at Object.req [as require] (c:\Users\HOME\Desktop\NodeScripts\node_modules\natives\index.js:55:10)
at Object.<anonymous> (c:\Users\HOME\Desktop\NodeScripts\node_modules\graceful-fs\fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
Process exited with code 1
First note encountering this kind of issue is not common when using Node.js. The packages webshot and flatiron haven't been maintained for 5 years at the time of writing, which is the primary reason they're incompatible with the current version of Node.js.
Typically when this error is encountered, you either need to use different packages, or downgrade to an older version of Node.js. According to the comments here, you should be able to downgrade to Node.js v11, but I highly suggest exploring more recently maintained packages like capture-website and express in order to stick with the latest LTS version of Node.js.

Getting: Error from phantom after upgrading to Node 6

after upgrading a MEAN stack application from 0.12 to node 6 we get the following error in our process.error log:
package/node_modules/phantom/lib/index.js:23 return new Promise(resolve => resolve(new _phantom2.default(args, config)));
and the process.output shows:
[2016-12-17 16:11:31.785] [ERROR] console - SyntaxError: Unexpected token >
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)
my version of phantomjs 1.9.8
this is the same problem reported previously:
phantomjs unexpected token
by some other user, but me being a relative newbie, I did not understand the answer or how it helps me fix the problem.
please direct me to a solution to this problem
This failure can be eliminated by using phantom versions prior to 2.0.0.
Notice that this is the phantom package and not the phantomjs package that is giving the error

Resources