Some mysterious is happening on my server and I don't know why. I'm trying to run a simple deploy script containing yarn install. The script is triggered by a POST request from a Gitlab CE server. The specs of the server:
Ubuntu 16.04
Nginx (mainline)
Node 6 / Npm 3
PHP 7.1
The webhook is received by a PHP file containing something like this:
exec('cd /var/www/example.com && sh deploy > deploy.log 2>&1 &');
The deploy file contains a few commands like git pull, composer install and yarn install. Everything is working fine, except for Yarn/NPM. It keeps complaining about this:
error /var/www/example.com/node_modules/node-sass: Couldn't find the binary sh
I've searched for hours (maybe days) to find a solution, but no success so far. Hope someone can help me (and someone else too).
error Couldn't find the binary cross-env NODE_ENV=development node_modules/webpa
ck/bin/webpack.js --watch --progress --hide-modules --config=node_modules/larave
l-mix/setup/webpack.config.js
Related
I'm new to AWS and I've gotten as far as getting the following error in Symfony:
Asset manifest file "/var/app/current/public/build/manifest.json" does not exist.
In local, this would be fixed by running npm run build. I've tried adding NPM_CONFIG_PRODUCTION=true in the environment variables, but I think that might just be for node.js apps?
I've also tried SSHing onto the EC2 instance and installing node on there, but I ran into errors trying to install either npm or nvm. I feel like this is the wrong approach anyway, since it seems like the idea of beanstalk is that you shouldn't need to ssh onto the instance.
Perhaps I should just include the node_modules folder in the zip uploaded, but since one of the recommended ways to produce the zip is to use git, this doesn't seem correct either.
After a lot of digging around, it seems like there's 3 options here:
SSH onto the instance(s) and the following worked for me (Amazon Linux 2 - ARM chip)
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
The problem with this, is if you have multiple instances that scale up and down with a load balancer, it isn't really practical to do this.
Add the above as a hook:
The following sh file could be put in the following directory: .platform/hooks/predeploy
#!/bin/bash
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
However, I've since learnt that it's best advised to just include the node_modules in the zip that gets uploaded. I guess this way the time to get the server up is reduced.
Include the node_modules folder in the zip that gets uploaded.
To include the node_modules folder, since this is naturally ignored by GIT, I used the EB CLI and added a .ebignore file, which is a clone of the .gitignore file, but includes the node_modules and public folders. Also be cautious in your build process that you're not including the node dev dependencies.
I'm using Laravel 7 on my windows 10 machine. While try to use Bootstrap, after executed the command php artisan ui bootstrap, i got the blow message.
Bootstrap scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.
When run npm install && npm run dev, i got the error:
The token && is not a valid separator in this version.
What should I do now? I've already installed node.js and even enabled the path in environment variable.
Appreciate if someone could help on this!
Because you are using Powershell. Three alternatives you have:
Try to use CMD or Gitbash.
you can use try this command:
(npm run build) -and (node ./dist/main.js)
Run them separetly. npm install and npm run dev
before i start, i need to say that i'm aware that this question is a beginner's one.
I've found this dashboard combination of Laravel and Vue.js that i wanted to play with, to then start developing a real web application. laravue
There's just a single question that is confusing me: while testing it on xampp with the commands "npm run watch" and "php artisan serve" i see myself obliged to npm run the project, every time i make a file change.
So what is the right way to check all the changes i make? By just refreshing the browser window.
Thank you for all the responses.
I've solved the problem by running "npm run watch" and "php artisan serve" on two separated command-line windows.
Was totally unaware of that and it's part of the learning curve.
Thank you, this is now solved.
npm run watch automatically builds your assets and then watch any save on the concerned files. Whenever a save happens, npm run watch rebuilds everything, but you won't be aware on your web browser except by refreshing.
P.S: Sometimes npm run watch does not work well, then use npm run watch-poll instead
https://laravel.com/docs/7.x/mix#running-mix
npm run watch or npm run watch-poll will automatically rebuild your assets but don't apply to the browser without manual refresh. Meaning you have to reload browser after compiling done.
Hot Module Replacement(HMR - or Hot Reloading) works same as npm run watch and apply changes to browser automatically, so you don't have to reload browser to see the changes.
Following this document, HRM works well with the fresh installation (latest code on master) as my test.
npm run hot result:
➜ npm run hot
> laravue#0.11.0 hot [src]
> cross-env NODE_ENV=development BABEL_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js
ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from http://localhost:8080/
ℹ 「wds」: Content not from webpack is served from [src]/public
ℹ 「wds」: 404s will fallback to /index.html
php artisan serve result:
➜ php artisan serve
Laravel development server started: http://127.0.0.1:8000
And browser:
Since laravel 6 the new way to implement authentication you have to get laravel/ui package via composer by running composer require larvel/ui then you have to generate the scaffolding you need here mine is bootstrap php artisan ui bootstrap --auth then you run npm install to get the node_modules and lastly you run npm run dev to build your assets. But the problem is when I run npm run dev nothing happens and I have no errors displayed in the console. When I opened the package.json file I've noticed that the npm run dev executes the npm run development command. So I tried to directly run npm run development and still nothing happened. The npm run development command consist of running this command "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" So I tried to run that and it compiled all the assets. So it is working but what I don't get is why npm commands aren't working either it is "npm run development" "npm run watch" or any other command they don't execute they just throw a new prompt with no error message.
(node -v) v12.16.0
(npm -v) 6.12.0
(laravel -v) Laravel Installer 3.0.1
(composer -v) version 1.9.0
This did the trick for me guys. I remember that I've once put npm config set ignore-scripts to true and that's the reason why it ignores the scripts in package.json. The solution is to change it to false
If have installed the Git Bash and Heroku CLI separately.I am using a 32-bit windows operating system.When I am typing " heroku login" command in cmd I am getting the login option but in Git Bash its showing Heroku command not found.
# MINGW32:/
HOME#HOME-PC MINGW32 /
$ heroku login
bash: heroku: command not found
I am not able to reproduce this issue, but it seems pretty common and known.
According to this is issue on Github heroku-cli project,
I closed out Git Bash then opened the command prompt. From there, I
was able to successfully login to heroku through "heroku login". I
then closed the command prompt and re-launched Git Bash and everything
worked fine.
This workaround worked for a few people, however the issue is still open.