node js error in render (template show) - node.js

when i trying to create template and node execute that gives this error please help me
Error: Failed to lookup view "default" in views directory "C:\Users\Act027\Desktop\node\views"
at EventEmitter.app.render (C:\Users\Act027\Desktop\node\node_modules\express\lib\application.js:519:17)
at ServerResponse.res.render (C:\Users\Act027\Desktop\node\node_modules\express\lib\response.js:904:7)
at C:\Users\Act027\Desktop\node\app.js:7:6
at Layer.handle [as handle_request] (C:\Users\Act027\Desktop\node\node_modules\express\lib\router\layer.js:82:5)
at next (C:\Users\Act027\Desktop\node\node_modules\express\lib\router\route.js:100:13)
at Route.dispatch (C:\Users\Act027\Desktop\node\node_modules\express\lib\router\route.js:81:3)
at Layer.handle [as handle_request] (C:\Users\Act027\Desktop\node\node_modules\express\lib\router\layer.js:82:5)
at C:\Users\Act027\Desktop\node\node_modules\express\lib\router\index.js:235:24
at Function.proto.process_params (C:\Users\Act027\Desktop\node\node_modules\express\lib\router\index.js:313:12)
at C:\Users\Act027\Desktop\node\node_modules\express\lib\router\index.js:229:12

You are either in the wrong folder or you have no view named "default".

Related

Log IP of request causing a decodeURIComponent error

I now get this error in my NodeJS server's logs:
[2021-11-13T14:43:45.107Z] URIError: Failed to decode param '/cgi-bin/%%32%65%%32%65/bin/sh'
at decodeURIComponent (<anonymous>)
at decode_param (~/node_modules/express/lib/router/layer.js:172:12)
at Layer.match (~/node_modules/express/lib/router/layer.js:123:27)
at matchLayer (~/node_modules/express/lib/router/index.js:574:18)
at next (~/node_modules/express/lib/router/index.js:220:15)
at expressInit (~/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (~/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (~/node_modules/express/lib/router/index.js:317:13)
at ~/node_modules/express/lib/router/index.js:284:7
at Function.process_params (~/node_modules/express/lib/router/index.js:335:12)
at next (~/node_modules/express/lib/router/index.js:275:10)
at query (~/node_modules/express/lib/middleware/query.js:45:5)
at Layer.handle [as handle_request] (~/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (~/node_modules/express/lib/router/index.js:317:13)
at ~/node_modules/express/lib/router/index.js:284:7
at Function.process_params (~/node_modules/express/lib/router/index.js:335:12)
It seems related to Apache's path traversal vulnerability. My server does not run Apache but I would still like to blacklist the IP address. This request does not print to the logs, and does not call my app's code in app.js.
How can I log the IP of the request?

Error: EPERM: operation not permitted, symlink

I am trying to create a sharepoint workbench, but after following all directions from microsoft docs and video to torials. I have also used
npm config set proxy http://proxyaddress.com:8080
npm config set https-proxy http://proxyaddress.com:8080
just in case network was getting in the way.
Anyone happen to know what direction i should take with this error?
[Full Error]
Error: EPERM: operation not permitted, symlink 'H:\helloworld-webpart\node_modules#microsoft\sp-webpart-workbench' -> 'H:\helloworld-webpart\temp\workbench-packages#microsoft_sp-webpart-workbench'
at Object.symlinkSync (fs.js:909:3)
at WorkbenchPage._getUrlForWorkbenchPackagePath (H:\helloworld-webpart\node_modules\#microsoft\sp-webpart-workbench\lib\api\WorkbenchPage.js:206:17)
at WorkbenchPage._generateWorkbenchPageContent (H:\helloworld-webpart\node_modules\#microsoft\sp-webpart-workbench\lib\api\WorkbenchPage.js:72:39)
at WorkbenchPage.handleWorkbenchRequest (H:\helloworld-webpart\node_modules\#microsoft\sp-webpart-workbench\lib\api\WorkbenchPage.js:26:51)
at Layer.handle [as handle_request] (H:\helloworld-webpart\node_modules\express\lib\router\layer.js:95:5)
at next (H:\helloworld-webpart\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (H:\helloworld-webpart\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (H:\helloworld-webpart\node_modules\express\lib\router\layer.js:95:5)
at H:\helloworld-webpart\node_modules\express\lib\router\index.js:281:22
at Function.process_params (H:\helloworld-webpart\node_modules\express\lib\router\index.js:335:12)
at next (H:\helloworld-webpart\node_modules\express\lib\router\index.js:275:10)
at _setJSONResponseContentTypeMiddleware (H:\helloworld-webpart\node_modules\#microsoft\gulp-core-build-serve\lib\ServeTask.js:119:9)
at Layer.handle [as handle_request] (H:\helloworld-webpart\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (H:\helloworld-webpart\node_modules\express\lib\router\index.js:317:13)
at H:\helloworld-webpart\node_modules\express\lib\router\index.js:284:7
at Function.process_params (H:\helloworld-webpart\node_modules\express\lib\router\index.js:335:12)
references:https://learn.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment
The underlying issue was that I installed to the wrong directory. I installed on a shared drive and not the local drive.

Problem in starting REST server using hyperledger composer

I have setup hyperledger fabric and also started network.But when I
create composer-rest-server and access it on my browser and access
https://localhost:3000/explorer
I'm getting an error:
Unhandled error for request GET /explorer: Error: Cannot GET /explorer
at raiseUrlNotFoundError (/usr/local/lib/node_modules/composer-rest-
server/node_modules/loopback/server/middleware/url-not-found.js:21:17)
at Layer.handle [as handle_request]
(/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:317:13)
at /usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:335:12)
at next (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:275:10)
at /usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:635:15
at next (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:260:14)
at Function.handle (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:174:3)
at router (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:47:12)
at Layer.handle [as handle_request]
(/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:317:13)
at /usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:335:12)
at next (/usr/local/lib/node_modules/composer-rest-
server/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/usr/local/lib/node_modules/composer-rest-
server/node_modules/body-parser/lib/types/urlencoded.js:91:7)
After you start the server it asks certain question with you, one of them is
Specify if you want to enable the explorer test interface
Make sure you put yes in it

How can I improve express.js error stack trace?

I'm using Node with Express as an API. Currently this is the output if there is an unexpected error thrown:
"stack": "APIError: test error\n at new ExtendableError
(/home/user/workspace/test-api/server/helpers/error.ts:25:11)\n at new APIError
(/home/user/workspace/test-api/server/helpers/error.ts:41:5)\n
at app.use (/home/user/workspace/test-api/config/express.ts:112:24)\n
at Layer.handle_error (/home/user/workspace/test-api/node_modules/express/lib/router/layer.js:71:5)\n
at trim_prefix (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:315:13)\n at /home/user/workspace/test-api/node_modules/express/lib/router/index.js:284:7\n
at Function.process_params (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:335:12)\n
at next (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:275:10)\n
at Layer.handle_error (/home/user/workspace/test-api/node_modules/express/lib/router/layer.js:67:12)\n
at trim_prefix (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:315:13)\n
at /home/user/workspace/test-api/node_modules/express/lib/router/index.js:284:7\n
at Function.process_params (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:335:12)\n
at next (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:275:10)\n
at Layer.handle_error (/home/user/workspace/test-api/node_modules/express/lib/router/layer.js:67:12)\n
at trim_prefix (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:315:13)\n
at /home/user/workspace/test-api/node_modules/express/lib/router/index.js:284:7\n
at Function.process_params (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:335:12)\n
at next (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:275:10)\n
at /home/user/workspace/test-api/node_modules/express/lib/router/index.js:635:15\n
at Immediate.next (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:260:14)\n
at Immediate.<anonymous> (/home/user/workspace/test-api/node_modules/express/lib/router/index.js:635:15)\n
at runCallback (timers.js:812:20)\n
at tryOnImmediate (timers.js:768:5)\n
at processImmediate [as _immediateCallback] (timers.js:745:5)",
I would love it if I can display the file, linenumber and function where this happened but I have no clue how to do this.
Can anyone help or point me in the right direction?
For reference, you can see the boilerplate my project is based on here. Express setup can be found in config/express.ts
Try adding source-map-support. Your stack trace is actually showing you the file and line number of the code that triggered an error but it seems to show it on transpiled code. Install the package and call install() inside your entry file:
$ npm install --save-dev source-map-support
// entry.ts
require('source-map-support').install();

MEAN.JS: Server username security

Using MEAN.JS is possible to bring a Server Error changing this:
http://localhost:3000/#!/
To:
http://localhost:3000/%C0#!/
Error: Bad Request
at SendStream.error (/home/username/Project/node_modules/express/node_modules/send/index.js:239:16)
at SendStream.pipe (/home/username/Project/node_modules/express/node_modules/send/index.js:411:32)
at serveStatic (/home/username/Project/node_modules/express/node_modules/serve-static/index.js:110:12)
at Layer.handle [as handle_request] (/home/username/Project/node_modules/express/lib/router/layer.js:82:5)
at trim_prefix (/home/username/Project/node_modules/express/lib/router/index.js:269:13)
at /home/username/Project/node_modules/express/lib/router/index.js:236:9
at Function.proto.process_params (/home/username/Project/node_modules/express/lib/router/index.js:311:12)
at /home/username/Project/node_modules/express/lib/router/index.js:227:12
at Function.match_layer (/home/ec2-user/Project/node_modules/express/lib/router/index.js:294:3)
at next (/home/username/Project/node_modules/express/lib/router/index.js:188:10)
We can see the username of the server and this is dangerous...
Any suggestion to solve this bug?
The solution is easy. Only need to modify the message of file app/views/500.server.view.html

Resources