Fail to start browser sync - node.js

I'm new to these things. I just started to learn web development through a free course in Coursera, and I'm having trouble in setting up the development environment.
That's what I did: installed Sublime Text 3, git and node.js. Created a repository on git, a web page with Sublime and committed it to git.
Now I'm trying to start browser sync but I'm getting this:
$ browser-sync start --server --directory --files "*"
[BS] Access URLs:
-------------------------------------
Local: http: //localhost:3000
External: http: //192.168.0.13:3000
-------------------------------------
UI: http: //localhost:3001
UI External: http: //192.168.0.13:3001
-------------------------------------
[BS] Serving files from: ./
[BS] Watching files...
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
I searched a lot but couldn't find a solution.
Browser isn't synchronizing.

One of the mentors of the course helped me with the solution.
The cause of this error was that it was missing the C:\Windows\System32\ variable in the System Variables. I added it and it solved my problem.

Related

"vitest --ui" causing "Error: spawn xdg-open ENOENT"

I'm trying to check out Vitest's fancy UI server in my node docker container. But can't get it up and running. When running the npm script vitest --ui I get a node error spawn xdg-open ENOENT.
Here the full error message:
$ npm run test-ui
> wpvite#0.0.0 test-ui
> vitest --ui
DEV v0.23.4 /home/node/apps/main/frontend
UI started at http://localhost:51204/__vitest__/
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn xdg-open ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn xdg-open',
path: 'xdg-open',
spawnargs: [ 'https://localhost:51204/__vitest__/' ]
}
Node.js v18.10.0
Google is no help at all - nothing related to Vitest even close. Also I'm obviously not a Node.js expert.
Even though the Node.js error message appears pretty cryptic to me, I still was lucky to use Ubuntu as my primary OS (beside macOS) which made me draw my attention to xdg-open in the error message - I occasionally use the command to open all kind of programs/apps on Ubuntu. Don't know why, but you need to have xdg-open installed on your system, to be able to run vitest --ui, even though it's neither mentioned in Vitest nor in Vite Github repos with a single word. Anyway for debian based containers it's:
apt install xdg-utils --fix-missing
Allthough this made the ENOENT error go away and the UI server starts up without errors, I still don't get to see the UI app due to some runtime-dom errors... I give it up. But maybe someone else finds the xdg-open info helpful.
UPDATE: It's working!
I just had to append /__vitest__/ to my proxied local url as clearly described in the docs:
"Then you can visit the Vitest UI at http://localhost:51204/__vitest__/"

node error when calling "yarn start" in an app created by create-react-app

I recently created a new project with create-react-app, installed all newest packages for an old create-react-app project (which was using react-scripts 3.4.1, and the new project is using 5.0.0) and copied the old code and asset files over. To my puzzlement, the new project throws an error whenever I call "yarn start"
Starting the development server...
node:events:498
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:442:9)
at TLSSocket.emit (node:events:520:28)
at TLSSocket.emit (node:domain:475:12)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
Node.js v17.4.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
For what it's worth, the old project doesn't throw an error despite that the src code is the same. The only difference is the packages.
I googled around and followed various advice, including this one: https://medium.com/#premal.katigar/how-to-fix-throw-er-unhandled-error-event-30172323a973. All to no avail.
There are a couple of clues that could be useful:
I use an antd landing page, which is basically a bunch of .jsx and .less files that constructs a page. If I replace that landing page code with some simple jsx component, e.g. something that simply returns an h1 tag, then there is no longer this node error. Yarn start would start the project fine.
The only differences between the old project that starts fine even with the aforementioned antd landing page, and the new one that throws the above error are that 1) the new project contains all the newest versions of the required packages, since I used "yarn install" for all the required packages 2) since I'm using the newest version of antd, instead of using "customize-cra", "react-app-wired", "babel-plugin-import" and "less-loader", I was simply using "craco-less". So the old project's "yarn start" actually called "react-app-rewired start" and the new one actually called "craco start".
I also tried downgrading node version from 17 to 16, and the error remained.
Any clue what might be the issue?

Gulp crash with an HPE_INVALID_CONSTANT error on first XHR request

I'm developing an AngularJS 1.7.x application (started 3 years ago), and when I started Gulp was the tool to use.
Yesterday, when I resume my work on my app, I suddenly get a crash on the first XHR request.
So I run "gulp serve", it opens chrome with the login page, everything is loading correctly, and then, I click the login button, which issue a REST call to my PHP Backend (served by Apache/2.4.37 (Unix) PHP/7.2.14)
The package.json of my project didn't changed in quite some time.
I've recently updated npm (6.9.0) & node (8.11.1), but it's not that recent.
[12:14:13] Starting 'serve'...
[HPM] Proxy created: /rest -> http://localhost/
[12:14:13] Finished 'serve' after 49 ms
[BrowserSync SPA] Running...
[Browsersync] Access URLs:
--------------------------------------
Local: http://localhost:3000/
External: http://192.168.1.21:3000/
--------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
--------------------------------------
[Browsersync] Serving files from: .tmp/serve
[Browsersync] Serving files from: src
[HPM] Error occurred while trying to proxy request /rest/authenticate from localhost:3000 to http://localhost/ (HPE_INVALID_CONSTANT) (https://nodejs.org/api/errors.html#errors_common_system_errors)
events.js:183
throw er; // Unhandled 'error' event
^
Error: write after end
at write_ (_http_outgoing.js:622:15)
at ServerResponse.write (_http_outgoing.js:617:10)
at IncomingMessage.ondata (_stream_readable.js:639:20)
at emitOne (events.js:116:13)
at IncomingMessage.emit (events.js:211:7)
at IncomingMessage.Readable.read (_stream_readable.js:475:10)
at flow (_stream_readable.js:846:34)
at resume_ (_stream_readable.js:828:3)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
In my php Backend, my configuration file was giving an empty "ReCaptcha" secret, which end up producing this crash on gulp/proxy...
Can't understand why the error thrown by ReCaptcha can mess up the proxy so much...

Unable to run (gulp serve) Google Polymer Starter Kit v1.1.0 on Windows

I need help please!
I have been able to effortlessly install and run all previous versions of the PSK. I have spent hours now trying to get 1.1.0 to run in my environment. I have done everything I can think of. From googling the error to reviewing all current issues with this version here. Any of the suggested fixes dont work for me.
I have made no code changes and I am running CMD as the Admin.
When I grab a fresh copy of the repository and do the NPM & Bower installs, then run "gulp serve" I get the following error no matter what:
C:\FrontEnd\polymer-starter-kit>gulp serve
[09:45:33] Using gulpfile C:\FrontEnd\polymer-starter-kit\gulpfile.js
[09:45:33] Starting 'styles'...
[09:45:33] Starting 'elements'...
[09:45:33] Starting 'images'...
[09:45:33] Finished 'elements' after 249 ms
[09:45:33] styles all files 98 B
[09:45:33] Finished 'styles' after 590 ms
[09:45:34] images all files 35.41 kB
[09:45:34] Finished 'images' after 357 ms
[09:45:34] Starting 'serve'...
[09:45:34] Finished 'serve' after 73 ms
[PSK] Access URLs:
------------------------------------
Local: http://localhost:5000
External: http://xxx.xxx.x.x:5000
------------------------------------
UI: http://localhost:3001
UI External: http://xxx.xxx.x.x:3001
------------------------------------
[PSK] Serving files from: .tmp
[PSK] Serving files from: app
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:837:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at doNTCallback2 (node.js:429:9)
at process._tickCallback (node.js:343:17)
My Environment:
All Required Prerequisites
Windows 10
Node.js v4.1.1
NPM v3.3.4
Bower v1.5.3
I am also not sure how to get a more detailed stack trace.
What should I do?
Thanks for the help!
It turns out I needed to add C:\Windows\System32 to my PATH vars. So strange. When I did that everything work like a charm.

error when starting the server with grunt or node server

I am trying to use the mean stack as described here : http://mean.io/
after install, when making "grunt", there is an error :
debugger listening on port 5858
4 Jan 01:47:40 - [nodemon] reading ignore list
Express app started on port 3000
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
4 Jan 01:47:40 - [nodemon] app crashed - waiting for file changes before starting...
I tried the troubleshooting as specified on the site : Updating Grunt, bower and cleaning npm and bower caches worked well. but updating npm gives an error too:
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
This looks like a conflict between homebrew and npm.
but anyway i have version 1.3.21 installed.
There is the same error when i am trying node server.
do you have an idea on what i can do to make the server work ?
It may be too easy, but seems like your MongoDB server is not actually running. After having installed Mongo (on your Mac, I assume?), you have to open a Terminal window/tab, run mongod and leave it running (or use screen, etc.). You can try to access MongoDB CLI by typing mongo to make sure the server is running.
#desgnl: if you don't want to run mongod command everytime you are running the grunt, you can always use third party services like MongoDB Hosting: Database-as-a-Service by MongoLab https://mongolab.com Hope this helps too!

Resources