Start-server-and-test "server closed unexpectedly" - node.js

I'm using the start-server-and-test package to start a server on my Azure pipeline to run Cypress.
This is the yarn command I use to start everything: yarn cy:build:workspace
"cy:build:workspace": "yarn cy:clean && start-server-and-test start http://localhost:8080 cy:run:workspace"
I'm running NODE_VERSION: "12.10.0" on the Azure env.
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "d:\a\_temp\ce28689e-eef6-4eeb-bad2-82310f748e1b.cmd""
yarn run v1.22.4
$ yarn cy:clean && start-server-and-test start http://localhost:3000 cy:run:workspace
$ rimraf cypress/reports/*
1: starting server using command "npm run start"
and when url "[ 'http://localhost:3000' ]" is responding with HTTP status code 200
running tests using command "npm run cy:run:workspace"
> #someProjectsbs/suite-packages#0.1.1 start D:\a\1\s
> lerna exec --scope=#someProjectsbs/suite -- yarn start --all-apps
lerna notice cli v3.20.2
lerna info ci enabled
lerna notice filter including "#someProjectsbs/suite"
lerna info filter [ '#someProjectsbs/suite' ]
lerna info Executing command in 1 package: "yarn start --all-apps"
$ cross-env react-app-rewired start --extended-linting --all-apps
[]
[info] [webpackbar] Compiling #someProjectsbs/suite
(node:4672) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
i 「wds」: Project is running at http://192.168.0.100/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from D:\a\1\s\packages\app\suite\public
i 「wds」: 404s will fallback to /
Starting the development server...
lerna success exec Executed command in 1 package: "yarn start --all-apps"
Error: server closed unexpectedly
at ChildProcess.onClose (D:\a\1\s\node_modules\start-server-and-test\src\index.js:69:14)
at ChildProcess.emit (events.js:209:13)
at ChildProcess.cp.emit (D:\a\1\s\node_modules\start-server-and-test\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
##[error]Cmd.exe exited with code '1'.
Finishing: Run Cypress testsk
Locally I have everything running, any suggestions why the server stops on the Azure environment?

Check your package.json, if you are using "react-scripts": "3.4.1" downgrade to 3.4.0
Also verify this link to use start-server-and-test with yarn, you need to add like strings some yarn commands https://github.com/bahmutov/start-server-and-test#note-for-yarn-users

Set the CI environment variable to true. Source: https://github.com/facebook/create-react-app/issues/8688#issuecomment-642309787

I had the same issue, but moving to wait-on solve the issue to me
https://docs.cypress.io/guides/guides/continuous-integration.html#Boot-your-server

Related

Running the cypress test cases getting failed with the Jenkins build "Error:read ECONNRESET"

Running the cypress tests (node v14.16.0, cypress 7.7.0) part of the Jenkins CICD pipeline and after successfully running couple of test cases getting the below error and the build is failing, please share if any resolution for the below issue.
Error Details:
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
{
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}
Error: Command failed with exit code 1: npx cypress run --browser=chrome --env coverage=true --config video=false --spec **/*.spec.ts
Solution Tried:
Had the issue in windows machine, and it is working fine by setting the cypress environment variable "CYPRESS_CRASH_REPORTS=0", but the similar fix does not work for the Jenkins build
Also tried upgrading some of the dependencies like "cypress", "start-server-and-test", angular-http-server" with the latest version but that does not resolve the build issue.
Package.config:
"test:ci": "cross-env CYPRESS_CRASH_REPORTS=0 start-server-and-test test:ci:http-server http-get://localhost:4200/../index.html "npx cypress run --browser=chrome --env covergae=true --config video=false --spec '**/*.spec.ts'""
"test:ci:http-server": "angular-http-server --silent --path ./client/+build --baseHref xxx/xxx/xxxxx -p 4200

Laravel Mix 6 ver upgrade error inpackage.json

My task is to upgrade package.json in Laravel. I haven't had any problems using Laravel-Mix 5 ver until now, but I got the following error after switching to 6 ver.
error: unknown option '--env.mixfile=webpack.admin.mix' error Command
failed with exit code 1. info Visit
https://yarnpkg.com/en/docs/cli/run for documentation about this
command. error: unknown option '--env.mixfile=webpack.client.mix'
error Command failed with exit code 1. info Visit
https://yarnpkg.com/en/docs/cli/run for documentation about this
command.
Perhaps the way "Scripts" is written may have changed. My Scripts in Package.json as below. Webpack.mix.js is divided by authority.
"scripts": {
"dev": "yarn run-p dev:admin dev:client dev:sp",
"dev:admin": "NODE_ENV=local yarn development -- --env.mixfile=webpack.admin.mix",
"dev:client": "NODE_ENV=local yarn development -- --env.mixfile=webpack.client.mix",
"dev:sp": "NODE_ENV=local yarn development -- --env.mixfile=webpack.sp.mix",
...
My env
PHP: 7.4.29
Laravel :8.76.2
Yarn: 1.22.5
Node: 16.14.2
Laravel Mix: 6.0.43
Already tried
Remake node_modules.
Yarn cache clear.
Deleted "-- --" in Scripts then try again.
What does the development script run?
In a default laravel mix package.json its mix. If that's the case you could try the following:
"scripts": {
"dev": "yarn run-p dev:admin dev:client dev:sp",
"dev:admin": "mix --mix-config=webpack.admin.mix.js",
"dev:client": "mix --mix-config=webpack.client.mix.js",
"dev:sp": "mix --mix-config=webpack.sp.mix.js",
...

mongodb folder absolute path in package.json error at 'C:\Program' is not recognized as an internal or external command

Have in my package.json some scripts as follow:
"start-admin-endpoints": "concurrently \"npm run mongo-start-admin-without-system-variable\" wait-on \"nodemon server.js\"",
"mongo-start-admin": " mongod --port 27017 --auth --storageEngine=wiredTiger --journal --dbpath=\"C:/data/db\"",
"mongo-start-admin-without-system-variable": " \"%ProgramFiles%/MongoDB/Server/4.2/bin/mongod\" --port 27017 --auth --storageEngine=wiredTiger --journal --dbpath=\"C:/data/db\"",
where its called by command: npm run start-admin-endpoints that originates the following error:
[0] > "%ProgramFiles%/MongoDB/Server/4.2/bin/mongod" --port 27017 --auth --storageEngine=wiredTiger --journal --dbpath="C:/data/db"
[0]
[0] 'C:\Program' is not recognized as an internal or external command,
[0] operable program or batch file.
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! errno 1
since already using %ProgramFiles% the windows alternative name to avoid the the space for the Program Files folder and the double quotes don't get why its still giving this error and how to fix (testing in windows 7).
Have it working in a windows 10 when the script "start-admin-endpoints": "concurrently \"npm run mongo-start-admin\" wait-on \"nodemon server.js\"", means that created in windows environment - system variables - path Have defined the path for mongodb as follow: C:\Program Files\MongoDB\Server\4.2\bin\
and its working well, but wanted also be able to use the absolute path in script in case of not having access to environment variables of windows.

Next.js - ERROR Build directory is not writeable on EC2

I'm running for the first time my Next.js app with a custom server.js on Elastic BeanStalk with 64bit Amazon Linux/4.11.0.
After the creation on the application, the environment and the deploy with the eb-cli I received a warning into the EB dashboard Environment health has transitioned from Degraded to Severe.
I changed the Node command into the config to npm run deploy. Nothing changed.
Here's my package.json.
"scripts": {
"start": "pm2 start server.js -i max",
"build": "next build",
"dev": "nodemon --exec babel-node server.js",
"start-next": "next start",
"deploy": "NODE_ENV=production next build && pm2 start server.js -i max",
"test": "echo \"Error: no test specified\" && exit 1"
},
I connected to the eb instance with eb ssh and after I've located the project dir I tried to execute npm run build but an error happened.
> NODE_ENV=production next build && pm2 start server.js -i max
> Build error occurred
Error: > Build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable
at build (/var/app/current/node_modules/next/dist/build/index.js:1:6361)
at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webreader-client#1.0.0 deploy: `NODE_ENV=production next build && pm2 start server.js -i max`
npm ERR! Exit status 1
I've created a .next directory with sudo but the error is still raised.
Docs:
https://github.com/zeit/next.js/blob/master/errors/build-dir-not-writeable.md
After spending nearly 4 hours on the phone with AWS support, their solution was as follows:
create a folder/file in the root of your project: .ebextensions/00_dir_permission.config
commands:
01_set_file_permissions:
command: "chmod 777 -R /tmp"
Of course this is less than ideal, but for some reason right now in EB permissions have changed such that you are not able to kick off the build without tweaking on permissions like this. Hoping this changes soon.
I was getting this same error locally and after about an hour of troubleshooting, I realized I had my node version set wrong. Seems like next 9.4 doesn't support version 9 of node. I updated to version 12 and it's working without issue.

with grapejs - did "npm start", but localhost:8080 will say This site can’t be reached localhost refused to connect

I downloaded the zip (from https://github.com/artf/grapesjs) and unzipped, then did the "npm i" command. That tooks a while, then I ran "npm start" and the console displayed this:
e:\GitHub\NealWalters\GrapeJSDemo>npm start
grapesjs#0.14.5 start e:\GitHub\NealWalters\GrapeJSDemo
npm run build:css -- -w & webpack-dev-server --open --progress --colors
grapesjs#0.14.5 build:css e:\GitHub\NealWalters\GrapeJSDemo
node-sass src/styles/scss/main.scss dist/css/grapes.min.css --output-style compressed "-w"
When I try http://localhost:8080 in the browser, I get the error:
This site can’t be reached
localhost refused to connect.
Here is my directory structure:
I have run other NodeJS programs before with success. Running on Windows 10.
On npm start, the process gets bound to watching files and doesn't reach the next command to startup the server. Try adding start in the beginning of the start script to run a separate process for watching the files. Then the command to startup the server will get executed.
So in package.json, change the start script to the following:
{
...
"scripts": {
...
"start": "start npm run build:css -- -w & webpack-dev-server --open --progress --colors"
}

Resources