I've made a project and pushed it to Github. Now when I clone it to my local server everything works fine. But when I'm on my live server and run npm run build it sometimes works (1 out of 10 times). I'm using Ubuntu 16 with nginx and I'm using simple webpack with vue. I also have the latest node and npm on my server.
I don't get any errors and warnings. After executing the command correctly it usually show that build.js and build map is created but. Most of the times it show nothing it only show that it is busy with optimizing but I'm not getting any results.
What I mean with: "It is sometimes working" is e.g when I run 8 times in a row npm run build WITHOUT changing any code it is finally working.
I'm very new to the JavaScript tools and what I understand is npm run build is to build my project and create a build.js file for my live server while npm run dev is for localhost.
Does anyone know what is the problem?
This is my package.json
{
"name": "front",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "My name",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^2.3.3",
"vue-authenticate": "^1.2.7",
"vue-echo": "^1.0.1",
"vue-resource": "^1.3.4",
"vue-router": "^2.7.0"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-preset-env": "^1.5.1",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"node-sass": "^4.5.0",
"sass-loader": "^5.0.1",
"vue-loader": "^12.1.0",
"vue-template-compiler": "^2.3.3",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
}
}
I don't know if this is relevant but this is my nginx block configuration:
server {
listen 80;
listen [::]:80;
root /var/www/my_project/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name my_project.com www.my_project.com
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
I just reinstalled my VPS and its working now. I don't know what was wrong, maybe node was installed wrong but i don't know if that even possible.. anyway its working now!
Related
I'm working on a react app, deployed and maintained through azure
devops. When I run prettier locally by command npm run
format:check then all files are formatted with message as All
matched files use Prettier code style!. But in azure pipeline I added
npm installer, with Command and arguments as run format:check , but it shows that Code style issues found in n files. Forgot to run Prettier?
package.json
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"devDependencies": {
"eslint": "^8.23.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.1",
"jest-editor-support": "^30.1.0",
"lint-staged": "^13.0.3",
"playwright": "^1.25.2",
"prettier": "^2.7.1",
"sass": "^1.54.4"
}
Which files does it say still need to be formatted? I'm guessing that these will be files which are generated at some point during the pipeline (e.g. node_modules, or build artifacts).
If so, the solution would be adding those files to the .prettierignore file
I generated a week ago an angular project with nrwl/nx at that time I could generate libs and components and could start my project but right now I am getting the following error:
spawn ENAMETOOLONG
This error occurs whenever I am trying to run npm run start which runs nx serve right now. ng serve is not working either. I can run npm install but nothing to start my application. Here is my package.json if you need any other information I can provide it:
{
"name": "moniesta-admin",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main",
"start": "nx serve",
"build": "nx build",
"test": "nx test"
},
"private": true,
"dependencies": {
"#angular/animations": "~13.2.0",
"#angular/cdk": "^13.0.0",
"#angular/common": "~13.2.0",
"#angular/compiler": "~13.2.0",
"#angular/core": "~13.2.0",
"#angular/forms": "~13.2.0",
"#angular/localize": "~13.2.0",
"#angular/material": "^13.2.2",
"#angular/platform-browser": "~13.2.0",
"#angular/platform-browser-dynamic": "~13.2.0",
"#angular/router": "~13.2.0",
"#nebular/auth": "^9.0.1",
"#nebular/eva-icons": "^9.0.1",
"#nebular/theme": "^9.0.1",
"#ng-bootstrap/ng-bootstrap": "^11.0.0",
"#nrwl/angular": "13.8.1",
"bootstrap": "^5.1.3",
"eva-icons": "^1.1.3",
"rxjs": "~7.4.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "~13.2.0",
"#angular-eslint/eslint-plugin": "~13.0.1",
"#angular-eslint/eslint-plugin-template": "~13.0.1",
"#angular-eslint/template-parser": "~13.0.1",
"#angular/cli": "~13.2.0",
"#angular/compiler-cli": "~13.2.0",
"#angular/language-service": "~13.2.0",
"#nrwl/cli": "13.8.1",
"#nrwl/cypress": "13.8.1",
"#nrwl/eslint-plugin-nx": "13.8.1",
"#nrwl/jest": "13.8.1",
"#nrwl/linter": "13.8.1",
"#nrwl/tao": "13.8.1",
"#nrwl/workspace": "13.8.1",
"#schematics/angular": "~13.2.0",
"#types/jest": "27.0.2",
"#types/node": "16.11.7",
"#typescript-eslint/eslint-plugin": "~5.10.0",
"#typescript-eslint/parser": "~5.10.0",
"cypress": "^9.1.0",
"eslint": "~8.7.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-cypress": "^2.10.3",
"jest": "27.2.3",
"jest-preset-angular": "11.0.0",
"prettier": "^2.5.1",
"ts-jest": "27.0.5",
"typescript": "~4.5.2"
}
}
EDIT:
This happens when i am using nx reset and after that using nx serve again:
Log file with the error: C:\Users\Hasan\OneDrive\Desktop\Moniesta-Projects\Moniesta-Combinatioon\moniesta-management\moniesta-admin\node_modules\.cache\nx\d\daemon-error.log
Please file an issue at https://github.com/nrwl/nx
Nx Daemon is going to be disabled until you run "nx reset".
In the Daemon log it just says the same error:
NX spawn ENAMETOOLONG
This error usually appears when you have too many uncommited files (in a range more than 700 or so in my experience). Commiting the files will usually solve the problem.
I just ran into the same issue. I did delete the node_modules folder manually, then re-installed everything with npm install. Also found that there is a new .angular folder in root folder, which was not present earlier. After deleting this folder entirely, I was able to run build again. Not really sure if running nx build once (which populates this folder again) you should not wipe it out once more.
I just ran into this issue. The solution that worked for me, I found it here
In my case, I was getting this error when running npm start, nx serve. After deleting the node_modules folder and running npm install, I found that running npm install was giving me this error too.
I had uncommitted changes on the branch. The error disappeared after committing the work.
I had the same issue and solve it like this:
First: Updating Nx to version 13.8.5. Do as below:
Run command: nx migrate #nrwl/workspace#13.8.5
Run command: npm install
Run command: nx migrate --run-migrations
Remove "migrations.json" file in nx workspace root directory
Second: Re-install npm globally based on nx version 13.8.5. Do as below:
Run command: npm i -g nx#13.8.5
I don't know why it's related to GIT but yes, having too many uncommitted files is the main cause of the problem.
In my case the reason was as #jurev described here, but the root cause of the problem was not so obvious.
I defined a local directory for a project and initialized local repo, then downloaded the project from remote repo into the directory and connected local repo with remote repo. As a result, I had nothing to commit but git status
showed that all of the files are not staged for further commit and nx serve.. returned spawn ENAMETOOLONG.
For me the solution was deletion whole project directory, downloading some client for version control system (for example, TortoiseGit) and clone the project from remote repo using the client and providing a link of the remote repo to it. After that nx serve worked perfectly.
I'm used to React and doing npm start to get my app running locally. However, when I run that on my new project it prompts that there is no start script. And upon further inspection, there isn't one.
If this is what my package.json looks like how do I get this running locally?
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"#fortawesome/fontawesome-free": "^5.13.0",
"axios": "^0.19",
"bootstrap": "^4.5.0",
"cross-env": "^7.0",
"datatables.net": "^1.10.22",
"datatables.net-bs4": "^1.10.22",
"datatables.net-plugins": "^1.10.22",
"install": "^0.13.0",
"jquery": "^3.5.1",
"laravel-mix": "^5.0.9",
"lodash": "^4.17.20",
"moment-timezone": "^0.5.32",
"npm": "^6.14.9",
"popper.js": "^1.16.1",
"resolve-url-loader": "^3.1.2",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"vue-recaptcha-v3": "^1.9.0"
}
}
It's a Laravel environment using PHP for back end and Vue for front end. I feel really stupid for not knowing this, but when I search I'm also not finding anything.
I'm using PhpStorm, I downloaded XAMPP, Composer, and PHP. I'm not sure what I'm missing or need to do? Help, please. If I'm missing any information I can certainly provide it to the best of my ability.
I'm a dingbat, I realized I wasn't running backend. So.. I did php artisan serve and received this. Any suggestions?
[![enter code here][2]][2]
C:\Users\emzib\ValorSystems.com>php artisan serve
PHP Warning: require(C:\Users\emzib\ValorSystems.com/vendor/autoload.php): Failed to open stream: No such file or directory in C:\Users\emzib\ValorSystems.com\artisan on line 18
PHP Fatal error: Uncaught Error: Failed opening required 'C:\Users\emzib\ValorSystems.com/vendor/autoload.php' (include_path='.;C:\php\pear') in C:\Users\emzib\ValorSystems.com\artisa
n:18
Stack trace:
#0 {main}
thrown in C:\Users\emzib\ValorSystems.com\artisan on line 18
Try below steps
composer install
npm install
npm run dev
QUESTION:
When doing "node app" on my local machine, everything works.
But when I deploy my project to the Google App Engine, the instance is killed and I find the following error in my logs:
npm ERR! Invalid version: "1"
I looked at:
npm: Why is a version "0.1" invalid?
npm ERR! Invalid version: y
how to workaround npm "Error: Invalid version: "0.1" BUG?
What is the mistake I need to correct ?
The deployment process started by gcloud app deploy --version=deploy
always ends with:
ERROR: (gcloud.app.deploy) Error Response: [4] Timed out waiting for the app infrastructure to become healthy.
Here is my package.json
CODE:
package.json
{
"name": "Name",
"version": "1.0.0",
"description": "Desc",
"main": "app.js",
"engines": {
"node": "6.9.4",
"npm": "4.2.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"minify": "html-minifier --input-dir ./viewsCopy --output-dir ./views-minified --collapse-whitespace --html5 --minify-js true"
},
"author": "author",
"license": "copyright",
"dependencies": {
"bad-words": "^1.5.1",
"body-parser": "1.1*.1",
"connect-flash": "0.1.1",
"decimal.js": "^9.0.1",
"ejs": "2.5.5",
"events": "^1.1.1",
"express": "4.15.2",
"express-session": "1.15.2",
"express-validator": "3.2.0",
"fast-crc32c": "^1.0.4",
"firebase": "3.9.0",
"firebase-admin": "^5.2.1",
"fs": "0.0.1-security",
"glob": "7.1.1",
"helmet": "3.5.0",
"html-minifier": "^3.5.0",
"morgan": "1.8.1",
"multer": "1.3.0",
"nodemailer": "4.0.0",
"path": "0.12.7",
"raven": "^2.0.0",
"request": "^2.83.0",
"sanitize-html": "^1.14.1",
"uglify-js": "^3.0.6"
}
}
in my case was
"version": "1"
I've edited to
"version": "1.0.0"
and it fixes.
In package.json the 'engine' properties allows you to block the node.js application running on versions of CLI tools which are unsupported.
You can either remove or modify the values. From quickly looking at the gcloud documentation they are using the latest stable from node.js (v9.4.0) which is bundled with npm v5.6.0. You could allow your application to run with existing versions and greater by adding the greater than character before the version.
"engines": {
"node": ">6.9.4",
"npm": ">4.2.0"
},
package.json -> version semantics may need to be like 1.0.0
https://docs.npmjs.com/about-semantic-versioning
What fixed it for me was deleting node_modules and package-lock.json and reinstalling with npm install
As per the documentation provided over here for node-semver there may be an issue with the dependency packages versions being loaded
Double check these versions or remove all of these and then try, if it works then keep on adding one by one and ultimately when it stops working you know which version numbering is faulty
List is as follows which might be the possible suspects
"body-parser": "1.1*.1",
"fs": "0.0.1-security"
try to replace all dependency version with * , Same with npm version.
then run npm install.
I am not sure it will work or not but give it try.
Please remove package-lock.json file. That will fix a problem.
I was able to publish an app made with Angular Cli tool to Github Pages a few weeks ago, but now when I try to use the command ng github-pages: deploy I get the error: The specified command github-pages:deploy is invalid.. This github thread suggests that the command has been removed recently, and petersgiles recommended following these guidelines instead to publish pages:
1. npm install -g angular-cli-ghpages (doesn't work if its not global)
2.Then in your package.json
"scripts": { "deploy": "ng build -sm -ec -bh /repo name/ & ngh --silent=false",...
3.when you want to deploy npm run deploy
I followed these instructions, but got the error: Failed at the mybiography#0.0.0 deploy script 'ng build -sm -ec -bh /aboutme/ & ngh --silent=false'. My npm and node js are up-to-date, and the error suggests that the problem is inside my package.json file.
My terminal proceeds to render all five chunks of my program, but there's no link to follow to the website. Is there anything i can do to fix this? I completed my website, and just need somewhere to host it. I'm very lost as a beginner, so please point out any obvious mistakes or missing info.
package.json
{
"name": "aboutme",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"deploy": "ng build -sm -ec -bh /aboutme/ & ngh --silent=false",
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor" },
"private": true,
"dependencies": {
"#angular/common": "^2.3.1",
"#angular/compiler": "^2.3.1",
"#angular/core": "^2.3.1",
"#angular/forms": "^2.3.1",
"#angular/http": "^2.3.1",
"#angular/platform-browser": "^2.3.1",
"#angular/platform-browser-dynamic": "^2.3.1",
"#angular/router": "^3.3.1",
"core-js": "^2.4.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"#angular/cli": "^1.0.0-rc.1",
"#angular/compiler-cli": "^2.3.1",
"#types/jasmine": "2.5.38",
"#types/node": "^6.0.42",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
}
just wanted to update this old post with an answer that worked for me on this SO post: how to publish to github pages?
There is a new angular cli command to push to gh-pages, the old one no longer works. So you have to install the new command, build the project, then execute the push command.
Try this: (for mac) (does not require any changes to package.json) :
$ npm install -g angular-cli-ghpages
Push your code to a github repo and then run this in terminal: ng build --env=prod --base-href "https://yourgithubusername.github.io/yourprojectname/" here
'yourprojectname' is the name of your github repo, not your local
repo.
If everything works fine, then run : sudo angular-cli-ghpages and enter password.
I suspect ngh --silent=false throws an error. The command for running angular-cli-pages with verbose output at the time of this answer is ngh --no-silent
If you want to update your deploy script, take a look at the angular-cli-pages doc for commands to build and deploy:
> ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY/"
> ngh --no-silent
Here is the simple way without any third party plugin you can deploy angular project to GitHub pages.
STEP 1: Open angular.json of your angular repo.
STEP 2: change dist/your-project-name to docs/
STEP 3: ng build --prod --base-href=https://username.github.io/respository-name/
change username to your GitHub username & respositoryName to repository name of your project.
STEP 4: Commit docs folder to local repo and push to github.
git add .
git commit -m "generated deployables"
git push -u origin master
STEP 5: Open Github repo and open settings
STEP 6: Select master branch /docs folder in github pages.
Congrats !!
Here is VERIFIED step by step detailed guide Article on how to deploy angular project to github pages, if you want more detailed article.