So I've inserted pictures of my vsCode, I'm trying to use node (or nodemon, which never seems to work for me) how ever I get an error message each time. I've even tried moving around my code, any assistance would be greatly appreciated!
Change line 2 of app.js into
const hotel = require('./models/hotel.js/hotel');
The reason you got an error in the console was because the require directory is wrong.
Related
I'm seeing the mentioned error, with stack trace below
Error: Cannot find module 'src/auth/guards/jwt-auth.guard'
Require stack:
~/Documents/Code/nestjs-passport-learning/dist/src/user/user.service.js
~/Documents/Code/nestjs-passport-learning/dist/src/user/user.module.js
~/Documents/Code/nestjs-passport-learning/dist/src/app.module.js
~/Documents/Code/nestjs-passport-learning/dist/src/main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
This error makes no sense, though, as the user module/service is not looking for that auth file at all. It was at one time, but I removed it while trying to debug the error. It seems like something internal to node itself is bugged and still looking at an outdated version of the code.
What happened:
Code was working/running perfectly
I decided to add "UseGuards(JwtAuthGuard)" to one of my user.service methods
At the same time I decided to setup debugging, so I added a launch.json file
Tried running the code. It built, but had a ton of "can't find bla bla" errors at runtime.
I stopped the app and figured the error was do to me not exporting the class in auth.module and not importing the AuthModule in UserModule(which was true).
I fixed that error, and restarted
Now getting the error message above
I removed the "UseGuards(JwtAuthGuard)" and all imports to it and AuthModule import in UserModule, as well as the launch.json file(ie revert back to exactly the code that was running perfectly 10 minutes earlier)
Still getting the same error(despite there being nothing in the user module that looks for it.
Why is user.service.ts still looking for that jwt-auth.guard.ts file?
Other things I've tried:
removing the "jwt-auth-guard.ts" file itself
checking out an earlier version of the code where "jwt-auth-guard.ts" hadn't even been written yet
restarting my machine
Nothing worked, no matter what, I get that same error, despite the code not being any different the code that worked.
link to github repo
Any help would be greatly appreciated, as I have no idea what's going on, and no idea what to google to even try to fix this problem.
Alright, so after some fiddling in my application, I tried renaming my 'dist' folder to try it, and it worked! So I guess the "caching" was due to the dist folder.
Peace and happy coding!
I am relatively new to coding node and keep coming across barriers when trying to learn, I am following a course and when trying to run the attached code snippet I keep receiving error messages.
I have tried to follow all the suggested articles and advice I can find but can't get a result.
Can someone help? VS code - terminal output
You are in node env, you need to exit by press "control + D" and try it again.
I'm very new to Node.js and right now I'm looking at the traceback after an error. The traceback starts with something promising:
buffer.js:140
throw new TypeError('must start with number, buffer, array, or string')
The question is: how to find this buffer.js so I can start investigating?
Context and what I've done:
It's a custom app and I started it with babel-node index.js. I have little knowledge about babel or other such machinery.
I've searched the app's directory for buffer.js. I've found two files called buffer.js, but neither of them has this line 140 or anything resembling that.
From what I see babel-node is installed in my AppData/Roaming/npm. It's installed “globally”; again, I'm not quite sure what it means, maybe that it's on PATH. I've searched that directory as well and found (the same) two buffer.js files, neither of which is relevant.
My understanding is that this is a Node.js app, so I've searched the Node.js directory. Here I found two different buffer.js files from some promzard, but they're not what I'm after.
So how do I locate this file? Where else to look? Could it be that it's embedded into something and thus the name just a remnant?
Print the exception stack trace this will help you and it will show the complete path how error produced and at which line and file generating the error.
Write the following line in your function where you are catching the exception.
console.log(ex.stack);
for some reason I can't get my require to work, it should just find both models fine but the path for the file just won't work.
app
models
user.js
match.js
server.js
Seems like a simple fix but cannot seem to do it myself right now. I'm using (var User = require('/app/models/user.js');)
Thanks guys.
Actually you also can write it as,
var User = require('./app/models/user')
without even putting .js at the end, as it is added by default.. Just a tip to know :)
and here ./ means the current directory.
Hope it helps :)
I'm new to both zombie and cucumber-js, so I apologize if I leave out anything important. If you need something I missed, please just ask.
I'm trying to get cucumber-js/zombie up and running on my XP box. I've had several issues along the way, but, with help, have gotten past those. Now I'm getting a new one. I have a test feature file with test files before it (basically pulled from the cucumber.js page on github). I installed both cucumber and zombie with a -g since it didn't see it otherwise. When I run the command cucumber-js features\myfeature.feature, I get the following error:
<projfolder>\features\support\world.js
this.browser = new zombie.Browser();
^
TypeError: undefined is not a function
(followed by a stacktrace)
I.am.lost.
I would greatly appreciate ANY help that ANYONE can give me on this.
node v0.8.17
cucumber v0.3.0
WinXP
don't know how to tell a version of zombie
I understand that this is coming quite late to the question, and the author may have moved on to something else. It is to help others, who may come to this question
Hopefully, your zombie is set to this -
var zombie=require("zombie");
Having clarified that, you need to change your step from
this.browser = new zombie.Browser();
to:
this.browser=new zombie();
and that should work fine.
There is a lot more to that, for more help check this API out.