Error on see nestjs version and start new pro ject - nestjs

enter image description here
Error on see NestJS Version
if (er?.code !== 'ENOENT') {
^
SyntaxError: Unexpected token '.'

Related

Next.js middleware NextResponse host issue

I have a issue while using NextResponse middleware. The host doesn't get detected correctly. I just started a local dev server with yarn dev.
Code:
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/home')) {
return NextResponse.redirect(new URL('/test', request.url))
}
}
All this code throws an error: TypeError: Invalid URL
As I understand local server can't determine the url which comes from request.url because localhost and port part gets ignored.
Also typescript throws an error on new URL: Argument of type 'URL' is not assignable to parameter of type 'string | NextURL'.   Type 'URL' is missing the following properties from type 'NextURL': _basePath, _options, _url, absolute, and 6 more.
Any ideas how to fix it on next.js application?

Firebase Messaging : canno't read property of undefined addEventListener

I created a Firebase App using NodeJS/VueJS and trying to setup Cloud Messaging.
I created a firebase-messaging-sw.js file, and added messaging on my main.js.
On my app I included firebase and on my mounted I did this (as stated on the doc) :
const messaging = firebase.messaging();
messaging.getToken({ vapidKey: "<KEY>" })
.then((currentToken) => {
if (currentToken) {
console.log('client token', currentToken)
} else {
console.log('No registration token available. Request permission to generate one.');
}
}).catch((err) => {
console.log('An error occurred while retrieving token. ', err);
});
Then I am going to my webapp and I have the following error :
"Uncaught TypeError : cannot read property of undefined (reading 'addEventListener')"
This error kinda lost me since I don't know where does it come from.
When looking on the error I saw that :
Looking into the source register.ts it redirects me to this :
navigator.serviceWorker.addEventListener('message', e =>
messageEventListener(messaging as MessagingService, e));
But I don't understand the problem, I tried to describe as much as possible all the steps that leaded to the error. Even when I comment the code of my mounted I still have the error
Thanks in advance,

SyntaxError Unexpected token at test-script

I have a Collection that has POST requests in it.
This collections needs bearer token for auth.
The Pre-request script and Tests assertion is written at Collection level.
Problem: The collection works fine when ran in Postman, but when I run it in Azure… it throws “Syntax Error Unexpected token at test-script inside…”. And none of the assertions written at collection level is validated as indicated by 0 in report.
How can I resolve Unexpected token issue and have the assertions run. Thanks.
PRE-Request Script:
postman.setEnvironmentVariable("guid", genHexString(32));
const parse =require('csv-parse/lib/sync');
const holiday = parse(pm.environment.get("holiday"),{
});
Tests:
const responseData = pm.response.json();
const csv_data = pm.environment.get("test_data");
const parse = require('csv-parse/lib/sync');
const csv_parsed_json_data = parse(csv_data, {
});
pm.test("Response has a body", () => {
pm.response.to.be.withBody;
});
pm.test("response body is json", () => {
pm.response.to.have.jsonBody()
});
Error message in Azure
# failure detail
01. SyntaxError
Unexpected token .
at test-script
inside "Set library"
02. SyntaxError
Unexpected token .
at test-script
inside "Obtain Token"
03. SyntaxError
Unexpected token .
at test-script
inside "Introspection"
04. SyntaxError
Unexpected token .
at test-script
inside "test case for so and so "

Nodejs app crashes when trying to delete a not empty directory on cloudinary

When I try to delete a directory on Cloudinary using my API (written in nodejs), I get the error that the directory is not empty (normal) and the app crashes and I need to restart it.
Here is theerror:
{ message: 'Folder is not empty', http_code: 400 } undefined
{"error":{"request_options":{"protocol":"https:","slashes":true,"auth":"281316816918183:CDb7LmvgBfhnVABQsG9Oks4u0vM","host":"api.cloudinary.com","port":null,"hostname":"api.cloudinary.com","hash":null,"search":null,"query":null,"pathname":"/v1_1/dgreyehwz/folders/9ea364f98672f22279ec99f315c11087/images/aaaaaa","path":"/v1_1/dgreyehwz/folders/9ea364f98672f22279ec99f315c11087/images/aaaaaa","href":"https://api.cloudinary.com/v1_1/dgreyehwz/folders/9ea364f98672f22279ec99f315c11087/images/aaaaaa","method":"DELETE","headers":{"Content-Type":"application/x-www-form-urlencoded","User-Agent":"CloudinaryNodeJS/1.23.0","Content-Length":0}},"query_params":"","error":{"message":"Folder is not empty","http_code":400}},"level":"error","message":"uncaughtException: (no error message)\n No stack trace","exception":true,"date":"Sun Nov 08 2020 17:42:02 GMT+0200 (Χειμερινή ώρα Ανατολικής Ευρώπης)","process":{"pid":2272,"uid":null,"gid":null,"cwd":"J:\\Projects\\NodeJS\\Development\\smartSignageDev","execPath":"C:\\Program Files\\nodejs\\node.exe","version":"v14.15.0","argv":["C:\\Program Files\\nodejs\\node.exe","J:\\Projects\\NodeJS\\Development\\smartSignageDev\\index.js"],"memoryUsage":{"rss":76529664,"heapTotal":61935616,"heapUsed":36817504,"external":21319141,"arrayBuffers":19733004}},"os":{"loadavg":[0,0,0],"uptime":1854},"trace":[]}
[nodemon] app crashed - waiting for file changes before starting...
The code I use to delete a directory on Cloudinary is:
const cloudinary = require('cloudinary').v2;
cloudinary.api.delete_folder(req.query.folder, function (error, result) {
console.log(error, result);
The part
{ message: 'Folder is not empty', http_code: 400 } undefined
Is what the Cloudinary API returns for my delete request.
I am using the latest versions of nodejs and Cloudinary Node.js SDK.
Has anybody faced something similar or now what this error means?

Testing AngularJS express node app

I have an issue with testing my application with both jasmine-node and mocha (with zombie). The point is angular doesn't work with this test environment - when browser.visit "http://localhost:3000/" it displays only layout, and don't render any templates link. I guess javascript doesn't run in browser (I mean zombie object) at all. My test Is there any way to make it works? Or problem is different?
In jasmine spec that i copied from another project spec occures an error:
/home/alder/Node/angular-express-coffee/spec/app_spec.coffee:12
throw error;
^
ReferenceError: angular is not defined
at /js/services.js:4:3
at /js/services.js:6:4
in /js/services.js
So I guess javascript doesn't work too.
Update:
I add debug option and here what it displays:
➜ angular-express-coffee git:(master) ✗ mocha --require should --compilers coffee:coffee-script --colors -R spec --ui bdd
Given I am a new user
When I visit the home page
Zombie: GET http://localhost:3000/newPost => 200
Zombie: GET http://localhost:3000/ => 200
Zombie: GET http://localhost:3000/js/lib/jquery-1.7.2.min.js => 200
Zombie: GET http://localhost:3000/js/lib/bootstrap.min.js => 200
Zombie: GET http://localhost:3000/js/lib/angular.min.js => 200
Zombie: GET http://localhost:3000/js/app.js => 200
Zombie: GET http://localhost:3000/js/controllers.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/controllers.js
Zombie: GET http://localhost:3000/js/lib/jquery-1.7.2.min.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/lib/jquery-1.7.2.min.js
Zombie: GET http://localhost:3000/js/filters.js => 200
Zombie: GET http://localhost:3000/js/directives.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/directives.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/filters.js
Zombie: GET http://localhost:3000/js/lib/bootstrap.min.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/lib/bootstrap.min.js
Zombie: GET http://localhost:3000/js/lib/angular.min.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/lib/angular.min.js
Zombie: GET http://localhost:3000/js/services.js => 200
Zombie: GET http://localhost:3000/js/filters.js => 200
Zombie: GET http://localhost:3000/js/directives.js => 200
Zombie: GET http://localhost:3000/js/controllers.js => 200
Zombie: GET http://localhost:3000/js/app.js => 200
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/app.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/controllers.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/directives.js
Zombie: Unexpected token ILLEGAL SyntaxError: Unexpected token ILLEGAL
in /js/filters.js
Zombie: GET http://localhost:3000/js/services.js => 200
Perhaps the problem in coffeescript but i had add option to mocha. And is there any method to test angular apps without JsTestDriver propagated by Angular team.
Updated.
I had changed errors assertions to browser.errors.should.be.empty and it had shown me an error:
1) Given I am a new user When I visit the home page Then browser status shold be ok:
AssertionError: expected [ [Error: Unexpected token ILLEGAL],
[Error: Unexpected token ILLEGAL],
[Error: Unexpected token ILLEGAL],
[Error: Unexpected token ILLEGAL],
[Error: Unexpected token ILLEGAL],
[Error: Unexpected token ILLEGAL],
[Error: Unexpected token ILLEGAL],
[Error: angular is not defined] ] to be empty
at Object.empty (/home/alder/Node/angular-express-coffee/node_modules/should/lib/should.js:229:10)
at Context.<anonymous> (/home/alder/Node/angular-express-coffee/test/app_test.coffee:31:40)
at Test.Runnable.run (/usr/lib/node_modules/mocha/lib/runnable.js:184:32)
at Runner.runTest (/usr/lib/node_modules/mocha/lib/runner.js:300:10)
at Runner.runTests.next (/usr/lib/node_modules/mocha/lib/runner.js:346:12)
at next (/usr/lib/node_modules/mocha/lib/runner.js:228:14)
at Runner.hooks (/usr/lib/node_modules/mocha/lib/runner.js:237:7)
at next (/usr/lib/node_modules/mocha/lib/runner.js:185:23)
at Runner.hook (/usr/lib/node_modules/mocha/lib/runner.js:205:5)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Last update:
The problem was in assets pipeline, all js was disabled for Zombie browser. Now I change to js from coffee and it works. But I prefer coffee, So if anyone can solve it, i'll be grateful.
Can it be because of Mocha? I hear it can cause problems because of its name...
Have you tried the Angular Scenario Runner?

Resources