Playwright won't execute - node.js

I'm new to coding and automation tools. I have followed several install guides for playwright but to no avail (most recent one I have tried is the one on Carl Rippon dot com). I've been able to create scripts using the npx playwright codegen www.x.com . However trying to execute these as either a .js or a .ts doesn't seem to do anything at all. I get errors that look like this:
PS C:\Users\SamDavies\Desktop\playwright> node hello-world.js
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'C:\Users\SamDavies\Desktop\playwright\hello-world.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

It's possible that the contents of your desktop are not what you think they are. Especially on a corporate device you might find that your desktop is actually at:
C:\Users\SamDavies\OneDrive - Your Organisation Name\Desktop\
I'd recommend using tab completion or a directory listing to verify that the hello-world.js is definitely in your current working directory.

Related

How can I run and make changes to a cloned app on my local machine?

I am relatively new to development and currently need to run a client's app on my local machine in order to make and test the changes. I cloned the app from the github repo, but have been unable to run the app on my local machine.
I have used the npm install, then the npm start command, but it gives me this error
`"> node dist/server.js
node:internal/modules/cjs/loader:998
throw err;
^`
Error: Cannot find module '********\dist\server.js' at Module._resolveFilename (node:internal/modules/cjs/loader:995:15) at Module._load (node:internal/modules/cjs/loader:841:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', requireStack: []
}
Node.js v19.0.1"
I don't know how to proceed with this. Please help
Maybe You Are Missing environment variables. Get Them From The Client.

How to accept Payments with Stripe

So this is my first time using Stripe to integrate payments for a website. What I am trying to do is add Stripe to my terminal for it to work correctly but I am getting an error. I have created a "Server" folder along with a "Server.js" file and when I try to initialize a new project it throws me an error.
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Royces-MacBook-Air:Kingdom Website roycewilliams$ $ cd server/
bash: $: command not found
Royces-MacBook-Air:Kingdom Website roycewilliams$ cd server/
Royces-MacBook-Air:server roycewilliams$ npm init -y
node:internal/modules/cjs/loader:926
throw err;
^
Error: Cannot find module './lib/_stream_readable.js'
Require stack:
- /usr/local/lib/node_modules/npm/node_modules/readable-stream/readable.js
- /usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-stream.js
- /usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-group.js
- /usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/index.js
- /usr/local/lib/node_modules/npm/node_modules/npmlog/log.js
- /usr/local/lib/node_modules/npm/lib/cli.js
- /usr/local/lib/node_modules/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:923:15)
at Function.Module._load (node:internal/modules/cjs/loader:768:27)
at Module.require (node:internal/modules/cjs/loader:995:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/readable.js:12:30)
at Module._compile (node:internal/modules/cjs/loader:1091:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10)
at Module.load (node:internal/modules/cjs/loader:971:32)
at Function.Module._load (node:internal/modules/cjs/loader:812:14)
at Module.require (node:internal/modules/cjs/loader:995:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/npm/node_modules/readable-stream/readable.js',
'/usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-stream.js',
'/usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-group.js',
'/usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/index.js',
'/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js',
'/usr/local/lib/node_modules/npm/lib/cli.js',
'/usr/local/lib/node_modules/npm/bin/npm-cli.js'
]
}
Royces-MacBook-Air:server royce
williams$
You probably just need to get the dependencies from npm. Type npm i in the same directory of the project to get the dependencies. If you don’t have npm installed you need to install it first.
Did you create this folder by yourself or did you clone/download it from one of Stripe's examples/repos?
If you downloaded it from somewhere, can you share the link?
Edit: The quickstart guide also has steps that you can follow to setup your integration

'D\node-backend\node_modules\.bin\' is not recognized as an internal or external command

I created a simple server with express and was using nodemon as a dev dependency. But when I try to exec "npm run dev" getting the following error:
PS D:\R&D\node-backend> npm run dev
> backend#1.0.0 dev
> nodemon ./app.js
'D\node-backend\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:942
throw err;
^
Error: Cannot find module 'D:\nodemon\bin\nodemon.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
at Module._load (node:internal/modules/cjs/loader:780:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.1.0
PS D:\R&D\node-backend>
I tried different solutions from the net and reinstalled nodejs but nothing seems to work. I think there's an issue with where npm is trying to find the package. You can check code here.
I have the same problem in my react project and i found the problem from the folder structure.
I have to change the name of the folder from:
Module 3 practice M1&2 ===> Module 3 practice M1 and 2
for me that "&" is what causing the error
Hope this works

NestJS microservices "Cannot find module"

So, I'm trying to create my first microservice using NestJS, but the moment I try to run it, the service stops with this error:
[13:39:21] Found 0 errors. Watching for file changes.
Error: Cannot find module 'C:\Users\voryi\IdeaProjects\YWA\des_server\services\learning-service\dist\main'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
there's no main.js file in the first level of your dist directory. You can define the entry file by adding this to your nest-cli.json:
"entryFile": "learning-service/src/main"
the default is main
try npm run build and then restart your service
I use monorepo setup and this issue happens whenever I start the nestjs server from non-root folder by mistake.
Usually, removing the dist folder and restarting the nestjs server works for me.
In my case, the main.js file was inside src folder so I had to change the script to:
"start:prod": "node dist/src/main"
maybe simply use this inside the project,
npm i #nestjs/microservices

Can I run a node.js script from another directory? Using absolute path to script

Friends
I am using node to do automated testing using Appium
The tests run from a bash script that changes the current directory
The path to the test is absolute.
Given that the path to the script is: /Users/bob/appium/test.js and the current directory (from the POV of bash) is /Users/bob/wd/
I get the error:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/Users/bob/wd/test.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
It is true Error: Cannot find module '/Users/bob/wd/test.js' that file does not exist.
I am not used to node, I am not sure I can even do this.
Why is it looking in the current directory for ?
The contents of the script is:
// Empty test for debugging the rest of the system
"use strict"
async function main () {
console.log("Here I am")
}
main().catch(console.log);
There is a lot of stuff going on in my script, the role of this JS file (/Users/bob/appium/test.js) is not run any tests, but to let the rest of the framework do its thing.

Resources