Can't build a Web Project in TeamCity - ruby

I am using TeamCity as my CI server(mac).I am trying to build a web project. When I use grunt serve or grunt buildproduction after changing directory to the cloned folder,it's working perfectly fine.But when I do this via TeamCity server it is giving an error You need to have Ruby and Compass installed and in your system PATH for this task to work and gets aborted due to warnings. Ruby and Compass is already installed in the server.Please help me on this.
rm -rf $(pwd)/node_modules/*
rm -rf $(pwd)/bower_components/*
npm cache clear
npm install
npm install bower
npm install grunt-ftp-push --save-dev
bower install
grunt buildproduction
This is the Command Line buildstep which I used in Teamcity..

I would say you probably use a different user or the shell environment is different (interactive vs non-interactive) when you run these commands manually and when it runs through TC it can't find those packages in the environment/PATH

Related

Run script before installing packages with nodeLinker set to node-modules

I have to run a script (from my package.json file) before I run yarn install. The script sets up the configuration for a private package. In my .yarnrc.yml, I have nodeLinker: node-modules (and I want to keep it that way because I get other errors if I remove it).
The problem is that when I run yarn run myscript I have the following error:
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...
But I can't run install before the script since I have private packages that need the script before it gets installed.
I just switched from NPM to Yarn 3.2.0. With NPM, I was able to run the script before installing packages.

yarn berry run how to run installed packages

I see with yarn berry I get the plug'n'play feature instead of node_modules/
I couldn't find anything to suggest it supports running from installed packages.
For example with npm a workflow might be to run the installed version of webpack:
$ npm install --save-dev webpack
$ node node_modules/webpack/bin/webpack ...
A globally installed webpack might not be the same version. Worse yet, during Docker deployment, I get what's installed locally, the only node and npm are available globally. I thought I can do a preinstall script that does npm install -g yarn; yarn set version berry but then I'm not sure how to do webpack, jest, babel, etc, and the thought that I should have to install them all globally during the same preinstall hackaround seems like several steps backwards.
Is there some way to run from locally-installed packages that I'm missing?
I saw this possibly related question - Yarn Berry - Run a Node Script Directly
But the answer there seems a bit off the point - I'm not running any js, I'm trying to type in a package.json script, i.e. something that can run from the shell.
Why not just use yarn run <bin> (or simply yarn <bin>)? If you are in a repository set to use yarn berry, that will run any package bin file.
yarn node <file> will run any .js file with Plug n' Play set up. No need to install those dependencies globally, except for maybe yarn classic.
I was trying to do yarn some-bin and kept getting:
Couldn't find a script named "some-bin".
I eventually figured out it was because the package that provides some-bin is installed inside a workspace and not at the root of my project. So instead I had to run:
yarn workspace my-workspace some-bin
And that worked.

Do I have to install grunt locally or is it just best practice ...?

or neither.
I installed both grunt-cli and grunt globally as such
inst_grunt(){
# installs the grung-cli to
# /usr/local/lib/node_modules/grunt-cli
sudo npm install -g grunt-cli
# installs grunt based upon the package.json file to
# /usr/local/lib/node_modules/Grunt
sudo npm install -g
}
I thought I could simply run
grunt --gruntfile /Users/a/root/config/Gruntfile.js watch
as stated here:
How do I run grunt from a different folder than my root project
but alas I get this error:
as-MacBook-Air:config a$ grunt --gruntfile
/Users/a/root/config/Gruntfile.js grunt-cli: The grunt command line
interface. (v0.1.13)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or
grunt hasn't been installed locally to your project. For more
information about installing and configuring grunt, please see the
Getting Started guide:
http://gruntjs.com/getting-started
The grunt file is there so I'm assuming it is looking for a local grunt installation.
You do have to install it locally in order to call functions on it within the gruntfile.
This way your project can specify what version of Grunt should be used (edit) in your package.json file.

Laravel Forge deployment script fails with 'command not found'

Quick explanation: I have a staging and a production server, both with the same deployment script (the only difference is the repo branch the clone). The deployment script runs bower install which is globally installed on both servers.
To install it globally I changed npm config set prefix to /home/forge/.npm-packages and afterwards ran npm install -g bower (note sudo wasn't needed, that's the point of changing the prefix). Once again, this was done in both servers.
When I ssh into each server, and run bower -v, which bower it is clear the command DO exist, and it IS added to PATH env. It is the same output for both servers.
Manually running bower install on the project root works for both server.
The issue is the forge deployment script, which only fails on production (IKR? I don't know what was I expecting).
The actual output is:
/home/forge/.forge/provision-2394191.sh: line 8: bower: command not found
The interesting part is, in my attempt to debug, I manually ran provision-2394191.sh and it worked.
What is wrong with my production server?
Seems like adding the new /home/forge/.npm-packages to the $PATH using export was not enough. To solve this I had to manually add it to the /etc/environment file.

Grunt installation in windows

I am trying to install grunt in my system windows 7. I have downloaded grunt from github. When running grunt command its giving unrecognised command. Can anyone help me out in this?
You can install grunt globally via npm (downloading it from here https://nodejs.org/download/). Probably you will need to update your environmental variables (by adding '%USERPROFILE%\AppData\Roaming\npm' to $PATH) or simply restart your PC.
Then you should be able to run npm install -g grunt-cli from your PowerShell or Command Line. When the npm installation is ready you should have access to grunt command.

Resources