npm install after run the playwright image for docker getting below error - playwright

npm ERR! Tracker "idealTree" already exists
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-11-19T05_41_58_533Z-debug-0.log
I am setting up docker to execute playwright test

Related

Cypress and Gitlab CI/CD integration

Hey I'd like to run my cypress tests using gitlab pipelines. I've got the following docker image
FROM cypress/browsers:latest
ARG DIR="/usr/tests/e2e"
ENV NODE_MODULES_PATH="$DIR/node_modules"
WORKDIR $DIR
COPY ./tests/e2e/package*.json ./
RUN npm ci
which is built at the beginning of the pipeline as a first job. My .gitlab-ci.yml file looks as follows
image-e2e:
build and push a docker image
...
test-e2e-staging:
stage: test-staging
image: registry.gitlab.com/.../e2e:latest
script:
- cd tests/e2e
- npm run e2e:ci
environment:
name: staging
needs: ["deploy-frontend-staging", "deploy-backend-staging"]
dependencies: []
allow_failure: false
The e2e:ci command simply runs cypress
"e2e:ci": "cypress run --headless --browser chrome --config-file cypress/config/cypress.json",
But the job output on gitlab gives me a following error
> cypress run --headless --browser chrome --config-file cypress/config/cypress.json
sh: 1: cypress: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! e2e#1.0.0 e2e:ci: `cypress run --headless --browser chrome --config-file cypress/config/cypress.json`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the e2e#1.0.0 e2e:ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-01T12_59_51_436Z-debug.log
Can anyone tell me what I'm doing wrong here? Thanks a lot in advance. Also I got a cypress dependency in the devDependencies section in package.json. The image-e2e job gives me the following output
Step 6/6 : RUN npm ci
---> Running in ed278e712827
> cypress#9.5.4 postinstall /usr/tests/e2e/node_modules/cypress
> node index.js --exec install
so it looks like cypress has been successfully installed here
As it complains about cypress not found, why don't you simply switch to cypress/included docker image, no need to install cypress on the fly.

Docker with .NET 5.0 and React.js errors on run

I followed this Microsoft article about creating a React.js client with .NET 5.0 API
I am attempting to create the Dockerfile and am able to successfully run the docker container for the .NET side (autogenerated) with no problem. I am able to "docker build" the react app with no problem but I get an error when I run it.
reactfrontend#0.1.0 prestart /app
node aspnetcore-https && node aspnetcore-react
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn dotnet ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn dotnet',
path: 'dotnet',
spawnargs: [
'dev-certs',
'https',
'--export-path',
'/root/.aspnet/https/reactfrontend.pem',
'--format',
'Pem',
'--no-password'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactfrontend#0.1.0 prestart: `node aspnetcore-https && node aspnetcore-react`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactfrontend#0.1.0 prestart script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-10-27T12_34_43_487Z-debug.log
I was unable to find the script in the file structure to debug. Let me know if this is missing info
So I was able to get a workaround by using an nginx image to assist, not sure why this allowed it to work as opposed to a standard React Dockerfile.
# Step 1
FROM node:10-alpine as build-step
RUN mkdir /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build
# Stage 2
FROM nginx:1.17.1-alpine
COPY --from=build-step /app/build /usr/share/nginx/html
There's probably a more correct answer to this but for a band-aid fix, this worked for me.

LOOPBACK4 npm run docker:start ERROR '.' is not recognized as an internal or external command

I'm doing the try it out section in loopback4 oficial site:
https://loopback.io/doc/en/lb4/Authentication-Tutorial.html
But when i try to execute the next command:
npm run docker:start
I get the following error:
loopback4-example-shopping-monorepo#1.1.1 docker:start C:\Users\jmlascasas\Documents\Laboratorio Hanuman\loopback4-example-shopping
> ./bin/start-dbs.sh
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! loopback4-example-shopping-monorepo#1.1.1 docker:start: `./bin/start-dbs.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the loopback4-example-shopping-monorepo#1.1.1 docker:start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jmlascasas\AppData\Roaming\npm-cache\_logs\2019-11-27T10_43_56_262Z-debug.log
I tried to change the route and searched for answers on google but nothing solved my problem
npm run docker:start start a bash script behind the scene if you look into package.json,
"docker:start": "./bin/start-dbs.sh",
While you are using the window, so might be the case something wrong the script in window. You can try two option
Run the command in git bash
Run the command manually without npm
you can run these command which npm run docker:start does in pacakge.json
docker run --name mongo -p 27017:27017 -d mongo:latest
docker run --name redis -p 6379:6379 -d redis:latest

docker node image, npm start no such file or directory

I pulled node image. Now I am trying run container with mounted volume. My files (ExpressSite) are in "c:/Program Files/Docker Toolbox/ExpressSite"
Milosz#DESKTOP-TN8ARMD MINGW64 /c/Program Files/Docker Toolbox/ExpressSite
$ docker run -p 8080:3000 -v "$(pwd)":/var/www -w "/var/www" node npm start
npm ERR! path /var/www/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/var/www/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-04-16T15_06_09_756Z-debug.log
I am using Docker Toolbox on Windows. "/var/www" directory exists (c:/Program Files/Docker Toolbox/ExpressSite/var/www)
After banging my head against the wall, faced the problem: Using docker toolbox, only the main user directory is shared with the vm.
https://github.com/docker/kitematic/issues/2738
You need to place your source code inside your user directory
C:\Users\ in windows environment
\Home\ in a linux environment

Docker Container works locally but fails on server

I'm fairly new to docker and I'm kind of experimenting with Angular CLI app. I managed to run it locally through my docker container. It works great, but when I try running it from my server it fails.
Server is hosted on DigitalOcean:
512 MB Memory / 20 GB Disk / FRA1 - Ubuntu Docker 17.03.0-ce on 14.04
I used dockerhub to transfer my container to the server.
When logging the container it gives me this:
** NG Live Development Server is running on http://0.0.0.0:4200. **
63% building modules 469/527 modules 58 active ...s/#angular/compiler/src/assertions.jsKilled
npm info lifecycle angular-test#0.0.0~start: Failed to exec start script
npm ERR! Linux 4.4.0-64-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-test#0.0.0 start: `ng serve --host 0.0.0.0`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the angular-test#0.0.0 start script 'ng serve --host 0.0.0.0'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng serve --host 0.0.0.0
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular-test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular-test
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/src/app/npm-debug.log
Here is my Dockerfile:
# Create image based on the official Node 6 image from dockerhub
FROM node:6
# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app
# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app
# Copy dependency definitions
COPY package.json /usr/src/app
# Install dependecies
RUN npm install
# Get all the code needed to run the app
COPY . /usr/src/app
# Expose the port the app runs in
EXPOSE 4200
# Serve the app
CMD ["npm", "start"]
How come it runs locally and fails on server? Am I missing some dependencies?
ng serve is an angular-cli command. I'm guessing you need to install it globally in your docker file if you want to start your server like that on digital ocean:
RUN npm i -g angular-cli
I think it would be more typical to simply run the app using the naked node server in production. So your CMD would look more like this:
CMD ["node", "app.js"]

Resources