I'm currently building a Vue.js app using vue/cli-service#4.5.17.
The issue I'm having is that whenever I change a .vue file, the server does not recompile, restart, or do anything.
I use this command (through package.json) to run the server in development environment:
NODE_ENV=development vue-cli-service serve
My vue.config.js file is:
module.exports = {
devServer: {
host: 'localhost',
port: 8080,
hot: true
},
publicPath: '/'
}
This is the output, and it does not change if I edit a file while the server is running:
DONE Compiled successfully in 17169ms 12:01:45 PM
App running at:
- Local: http://localhost:8080/
- Network: http://localhost:8080/
Note that the development build is not optimized.
To create a production build, run npm run build.
EDIT: I would like to add that a friend who is working on the same project and who start the server the same way as I do has the expected watch/reload feature. Is there a hidden environment variable to set or something?
I also would like to add that I'm using WSL2 to start the development server.
Thanks for your help!
Ok, I found something.
This is an issue with WSL2 not being able to trigger file change notifications: https://github.com/microsoft/WSL/issues/4739 .
I tried using Vite and with adding:
server: {
watch: {
usePolling: true
}
}
To the vite.config.js, it does work properly with WSL2 as explained here.
Related
I've configured IntelliJ to use python via a stack I've defined in docker-compose. I'm configured my project to execute my pytest via docker-compose so that I can use the debugger. However, I've discovered that after the initial run, when I change my code and re-run my tests, pytest is not seeing my changes, but rather executing a cached version of the code.
The only way I've discovered to get around this is to invoke the File menu option Invalidate Caches and Restart. This is annoying.
This my compose file:
networks:
app: {}
services:
item-set-definitions:
build:
context: /Users/kudrykma/ghoildex/kudrykma/analytics/sa-item-set-definitions
target: build
command:
- /bin/bash
image: item-sets:test
networks:
app: {}
volumes:
- source: /Users/kudrykma/ghoildex/kudrykma/analytics/sa-item-set-definitions
target: /project
type: bind
version: '3.9'
In the pytest Run configuration I've tried adding -force-recreate option in the docker-compose Command and options field but IntelliJ won't recognize it.
Does anyone know how I can configure IntelliJ to not cache any of my source file so that pytest will see my changed code?
Thank you
I'm getting broken index.html after vuepress build docs with lots of Failed to load resource: net::ERR_FILE_NOT_FOUND in console.
vuepress dev docs, however, works totally fine!
My steps:
Created new project with vue-cli 3;
Made yarn add -D vuepress;
Added folders and files:
-docs
|
--.vuepress
| |
| --config.js
|
--guides
| |
| --README.md
--info
| |
| --README.md
|
--README.md
My config.js:
module.exports = {
title: 'Hello VuePress1',
description: 'Just playing around',
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' },
{ text: 'Вернуться в приложение', link: '/desktop/' }
],
sidebar: [
'/',
'/guides/',
'/info/'
]
}
}
Now, vuepress dev docs gives at localhost:8080 exactly what i expect - everything is fine.
vuepress build docs generates dist folder, which contains:
assets folder
guides folder
info folder
404.html
index.html
Problem arises on opening index.html. Everything is displayed without CSS and links are not working. Seems like problems with paths to assets...
Why everything doesn't work properly out of the box in a completely new project?
The paths to the CSS and JS files in index.html are absolute (starts with /), so viewing index.html using the file protocol doesn't work (you need to host it on a server so the HTTP protocol are used).
you must run http server to open this file.
open cmd in this folder, and run:
with python: python -m http.server
with nodejs:
Install http-server by typing npm install -g http-server
Change into your working directory, where yoursome.html lives
Start your http server by issuing http-server -c-1
I have a CakePHP Application with codeception-plugin for testing.'
Locally I run it in a ddev docker environment and everything works fine.
Trying to run automated tests with gitlab-ci gives me following error:
Running with gitlab-runner 11.1.0 (081978aa)
on shared runner 601c0f11
Using Docker executor with image kevinliteon/cakephp:php7 ...
Starting service mysql:latest ...
Pulling docker image mysql:latest ...
Using docker image sha256:6a834f03bd02bb88cdbe0e289b9cd6056f1d42fa94792c524b4fddc474dab628 for mysql:latest ...
Waiting for services to be up and running...
*** WARNING: Service runner-601c0f11-project-94-concurrent-0-mysql-0 probably didn't start properly.
Health check error:
service "runner-601c0f11-project-94-concurrent-0-mysql-0-wait-for-service" timeout
Health check container logs:
Service container logs:
2018-10-04T12:12:18.904025613Z Initializing database
2018-10-04T12:12:18.925096235Z 2018-10-04T12:12:18.919745Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2018-10-04T12:12:18.925195518Z 2018-10-04T12:12:18.919970Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.12) initializing of server in progress as process 30
2018-10-04T12:12:50.330736417Z 2018-10-04T12:12:50.330487Z 5 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
*********
Pulling docker image kevinliteon/cakephp:php7 ...
Using docker image sha256:bd4a83b02647ad93a356b343d2ce5ae3a9a1177aea2cd76c61b009abc7df8990 for kevinliteon/cakephp:php7 ...
Running on runner-601c0f11-project-94-concurrent-0 via d7f4a5e71b47...
Fetching changes...
Removing vendor/
HEAD is now at 92cb022 test
Checking out 92cb0223 as deployment...
Skipping Git submodules setup
Checking cache for default...
Successfully extracted cache
$ vendor/bin/codecept run Unit
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
In Db.php line 308:
Db: SQLSTATE[HY000] [2002] Connection refused while creating PDO connection
My gitlab-ci.yml (partly):
services:
- mysql:latest
variables:
MYSQL_ROOT_PASSWORD: mysql123456789
MYSQL_DATABASE: test_db
MYSQL_USER: db
MYSQL_PASSWORD: db
build:
...
codecept:Unit:
stage: test
script:
- vendor/bin/codecept run Unit
In my codeception.yml I configured the Db module:
modules:
config:
Db:
dsn: 'mysql:host=mysql;dbname=test_db'
user: 'db'
password: 'db'
cleanup: true # reload dump between tests
populate: true # load dump before all tests
reconnect: true
I also tryed using the root user - without success.
Problem is, that I can not connect to the DB for whatever reasons... Maybe the warnings while initializing the service container have something to do with that, but I could not figure out how to fix them or if this is the problem.
I really tried a lot of things without any success! Basically my code depends on the documentations of gitlab-ci and codeception so it should work.
Anybody implemented this scenario successfully or know what I'm doing wrong?
Thanks for any help!
I want to answer how I solved it:
First thing was, I had to add the env-varibale "db_dsn" like this:
export db_dsn="mysql://user:paswd#host/db"
Then I still got the health-check error. Only way I found to successfully setup was to use another docker image for the db-service. I choose "mariadb:latest" - and then it worked for me.
I'm trying to get started with React using webpack, but keep running into an error when I try to set up webpack-dev-server. I ran
npm install webpack-dev-server
followed by
webpack-dev-server
and the command line returns the following:
events.js:154
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:26:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
Any clues on what is happening here?
I don't really know how webpack works to try and search for the root of the problem, but I've also been developing a website using PHP at port 80 with MAMP, I don't know if this is maybe part of the issue?
Solved, turned out my hosts file (found under /etc/hosts on a mac) had one line missing and so webpack couldn't find localhost. I restored it to its default following these instructions and it now works!
Make sure your /etc/hosts file includes localhost.
Open /etc/hosts
$ sudo vi /etc/hosts
Copy and paste this, if it's missing:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Did not work for me even after restoring the hosts file and trying with a different port. The way I made it to work was to give a custom host (127.0.0.1) and port (3001 or any other available) when starting the server:
webpack-dev-server --host 127.0.0.1 --port 3001
The most common reason for that error is that you have something else already using that port. Try starting it on another port.
webpack-dev-server --port 3001
Also check if /etc/hosts have 127.0.0.1 pointing to localhost as well.
Also encountered the same error and nothing fixed it.
It appears, in my case, that I accidentally "corrupted" the /etc/hosts file by been able to write to it without the sudo permission.
The clue was when I cat /etc/hosts the output was one messy line. I deleted and re-created the file as sudo, with the #lizzie-cd link and all went back to normal
In latest mac and linux os , the webpack dev server wokinnly only on adding the
host: "127.0.0.1"
inside the devServer in the webpack.config
Hosts file was fine. Going into web/dev.js and updating the file to the following fixed this issue for me. Still not sure why.
const webpack = require('webpack');
const merge = require('webpack-merge');
const path = require('path');
const { buildConfig, APP_PATH, WEB_PATH } = require('./common');
module.exports = (env, argv) => (
merge(buildConfig(env, argv), {
entry: path.join(WEB_PATH, 'index.hmr.js'),
devtool: 'inline-source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
devServer: {
contentBase: APP_PATH,
openPage: '',
inline: true,
stats: 'minimal',
open: true,
port: 3001,
hot: true,
host: "127.0.0.1"
},
})
);
Very strange. I had explicitly add the dev server port to my hosts file. E.g.
127.0.0.1 localhost:8001
Then npm run dev works again.
If that still does not work for you you could try removing node_modules completely and re-installing fresh.
rm -rf node_modules/
npm install # Or `yarn`
How do you run the Express 4 app with Forever? (or is there a new package?)
I am running my Express 3 apps with Forever installed locally with the package manager. I use the command:
forever -a start app.js
Try this:
forever start ./bin/www
Let's take a look to package.json:
"scripts": {
"start": "node ./bin/www"
},
I guess when we call npm start, ./bin/www will be executed at some point.
Then look at the content of./bin/www:
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
so we are ready to listen for connections.
forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www
If you use npm start to run your app, this works in place of it:
forever start -c "npm start" /path/to/app/dir/
Source: https://github.com/foreverjs/forever/issues/540
Try node app.js first, for me, I added a new module in code base, but i did not run npm install in my AWS box, forever is not giving you the error, it just stopped silently, but node will give you the error
http://expressjs.com/guide.html
in Expressjs guide doc,
use 'npm start'
I want use 'forever' but can not too
so,
add code at 'app.js'
var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
and
$node app.js
can use it.
and forever can use too
Feb 2021
This solution is for express.js & forever, on Windows OS.
package.json
"scripts": {
"start": "set PORT=3001 && set DEBUG=myapp:* && forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www",
}
Now run:
npm start
NOTE: For other OS, and customization see following link: https://expressjs.com/en/starter/generator.html