TeamCity with npm - Error: ENOENT, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm' - powershell

I'm having serious problems getting the last pieces of my TeamCity configuration in place.
I have a powershell step that executes the following commands:
& npm install
& grunt build
logging the following output:
Build (Powershell) (1s)
[13:18:08]PowerShell Executable: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
[13:18:08]Working directory: C:\BuildAgent\work\6a434ee5d01fd0d9
[13:18:08]PowerShell arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, C:\BuildAgent\temp\buildTmp\powershell8407335260182621582.ps1]
[13:18:09]Error: ENOENT, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'
[13:18:09]
[13:18:09]grunt-cli: The grunt command line interface. (v0.1.13)
[13:18:09]Process exited with code 0
I've seen that this is a known problem, but none of the solutions has worked for me so far.
My setup is the following: I have two virtual machines in Azure, build and agent. Both are connected to the same AD domain, domain, in which there is a user domain\teamcityuser, who is of "standard" class (i.e. not admin). This user runs both the build server (on the build instance) and the build agent (on the agent instance).
I've tried these things without success:
Creating the directory in the error message, making sure that domain\teamcityuser has full controll access rights to it.
Creating an npm directory under C:\Users\teamcityuser\AppData\Roaming
Creating a file C:\Windows\System32\config\SystemProfile\.npmrc with the contents prefix=C:\npm-global, as well as creating the latter folder
Running npm cache clean before running the build
Installing a global npm package through npm install -g npm
What more can I try to get this working?
And to avoid the XY problem, here's my actual problem:
I have a .NET Web API project with CI setup through this TeamCity installation, via Octopus Deploy and to the hosting server. I also have a github repo with the code for a web SPA that will consume the API. The spa is built with grunt build, after which there's a dist folder with everything I need to deploy.
I'd like to re-use as much as possible of the CI architecture to roll out the client too.

Given that path to executable contains SysWOW64, this is an x32 Powershell, therefore, it refers to x32 system profile path, which is located at C:\Windows\sysWOW64\config\systemprofile. So, you need to use that path as your base in order to implement any workarounds, say, create C:\Windows\sysWOW64\config\systemprofile\AppData\Roaming\npm folder, and not plain C:\Windows\system32\config\systemprofile\AppData\Roaming\npm.

Related

Fastlane working on terminal not on Jenkins

I am able to configure Fastlane locally and working well with terminal, but when I am trying to run it with Jenkins(I have configured Jenkins locally on my macbook) it is failing every-time(i have installed ruby 2.5.0 again).
Any help on the same would be highly appreciated.
I am attaching SS for your reference.
Jenkins run its build scripts using specified user 'jenkins'. You might want to check if 'jenkins' user had installed requires dependencies to run fastlane, for e.g ruby ...
Have you set up your PATH in Jenkins? In the configuration of your node, in the environment variables section, you'll want to include /usr/local/bin/ with Jenkins's PATH by entering /usr/local/bin/:$PATH.

Component-preload.js generation

We are about to close a SAPUI5 application, one of the last steps is to make a Component-Preload.js file to improve performance. I read different guides around the web, all of them need Node.js that I have installed. I'm not expert about that package and I can't figure how to make one of that guides work. I'm developing with NetBeans. As far as I see there is not an official tool (am I right?) to generate that file. Can someone with more experience than me suggest a working, well-explained guide to perform that task?
I don't know if this could help, that's my working tree:
There are several main ways of doing it.
You can use SAP Web IDE to generate it. This assumes that you are using WebIDE to develop your application (which is not true based on your question). The regular version of WebIDE generates this file during the "client build" just before application deployment.
The "multi cloud" version of WebIDE can use a grunt build to do it. You can find more info here if you are interested: https://www.sap.com/developer/tutorials/webide-grunt-basic.html.
Use the new UI5 command line tools (https://npmjs.com/package/#ui5/cli):
Run npm i -g #ui5/cli to install the tools globally.
Open the root of your project with your terminal.
Run ui5 build preload to build the preload.
Use the #sap/grunt-sapui5-bestpractice-build pre-configured grunt tasks. The downside is that they are more-or-less black boxes which do not allow that much customisation. You can find an example setup on SAP's GitHub repository jenkins-pipelines. In a nutshell:
You need to define an .npmrc file which adds the #sap npm registry: #sap:registry=https://npm.sap.com.
Run a npm init command such that you generate a package.json file. This file describes your application and your dependencies (runtime dependencies and dev dependencies; you will only have dev dependencies for now, as you just want to build your app). Make sure to mark the package as private. See the npm docu (at the end of the license chapter).
Then you can install grunt and the build configuration: npm i grunt -D and npm i #sap/grunt-sapui5-bestpractice-build -D.
Lastly you need to define a simple Gruntfile (you can then run the build by just running grunt):
module.exports = function (grunt) {
'use strict';
grunt.loadNpmTasks('#sap/grunt-sapui5-bestpractice-build');
grunt.registerTask('default', [
'lint',
'clean',
'build'
]);
};
You can use the official grunt_openui5 plugin to generate the preload file(s). In order to be able to do this, you need to have node installed:
Create a package.json (e.g. through npm init).
Install grunt by writting in the console: npm install grunt-cli --save-dev.
Install the official openui5 grunt plugin: npm install grunt-openui5 --save-dev.
Now you have all the tools necessary, you just need to tell grunt what it has to do. You should create a Gruntfile.js in the root of your project. In this file you should configure the grunt openui5 task as described in the official github page (I linked it above). You can find a similar file here (it has more build steps like minification and copying the result files in a separate directory).
You can then run the grunt build by simply running grunt <task_name> in the console. If you registered your build task as the grunt default task (like in the sample file: grunt.registerTask('default', [...]);) then you just have to write grunt.
I think you should be able to integrate such a command line script (i.e. to run grunt) inside your IDE as an external tool.
You can use the unofficial gulp-openui5 tool to generate it. I would not recommend this if you are not already using gulp for your builds (as it is not a tool built by SAP). The procedure is the same, but using gulp for building the app instead of grunt (so you need to install node, npm init, install gulp, create the Gulpfile, etc).
Note that for most of the above methods, you need nodejs, which you can download and install from here: https://nodejs.org/en/download/.

Azure private build agent : No agent could be found with the following capabilities: npm, azureps

I am trying to use a local server as a build agent to build a project. The server already has
VS 2015,
VS 2017
Node 6,7,8 via NVM
NPM 4,5,6 via NVM
I can build the project locally via npm build or yarn build.
I have downloaded and configured and registered the private build agent already and I have it in the agent pool in the portal - xxx.visualstudio.com/xxx.
But when I try to schedule a build from the portal the following message is displayed :
No agent could be found with the following capabilities: npm, azureps
What do I need to fix so the build can run locally?
The problem was simple - I did not see where the Capabilities tab was. IMHO Requests and Capabilities are not easily discoverable. I saw it and I set the two variables to true and it started to work even though I did not know for sure if true is the right value.
Another problem was that NVM SYMLINK was not working as expected and the build agent could not find node.exe at all. It was not in the PATH at all. I uninstalled nvm and used only node 8.1.2 with npm 5 in order to make it run.
UPDATE
As of today you can add a 'node tool installer' task to your definition - this is the better solution that is available today as D.J. points out in the comment section.

Are huge node_modules and bower_components directories necessary on production?

I'm deploying something into a remote server from my local development environment (vagrant / homestead). In my project I have huge directories for both node_modules and bower_components. I want to use rsync to deploy project on a remote server but I think it's OK to skip mentioned giants. Why?
By writing this question I would like to confirm 2 things:
1) Since I triggered gulp tasks on my local, is it all right NOT TO COPY those 2 vendor directories if my assets are already copied, minified and versioned using Laravel Elixir? Obviously compiled styles and scripts will be synced.
(that's non-Laravel project) but I use Elixir in my gulpfile.js for it's simplicity
2) Or should deployment process include installing assets (like npm install) on remote server and then running all tasks? I think it's wrong in that case. What if for example I won't be able to install and run npm on remote?
So in a nutshell. Can I consider node_modules and bower_components as essential resources only during development and redundant once deployed?
Yes you are right in that once the javascript app has been transpiled, all dependencies(node_modules, bower_componenets, etc) would have been removed by your gulp script and packaged into a single bundle.

Recommended approach to deploy VMware PowerCLI command line console application

PowerCLI with .NET has some dependencies on dll's that you get only when you install PowerCLI on each machine you want to run.
I have a console app with command line arguments, which when deployed using the usual method doesn't work because of the unmet dependencies...these assemblies are part of the GAC.
Clickonce deployment proved to be useless..it didnt recognize my arguments although I passed them as query params.
Finally, I installed VMware PowerCLI on this remote machine. Then ran the .exe and it worked. Is there a way to avoid installing PowerCLI and be able to include all the dependencies with my exe during deployment?
Depending on where exactly you want to deploy your console application, you may be out of luck. According to this page and the most relevant forum post I could find, the PowerCLI assemblies are not redistributable. Your best bet if you want to distribute this application outside your company is to use the Web Services SDK - a huge pain since you've already developed the app.
Assuming your application is for internal use only and you just want to deploy it on its destination server, you can do the following to reference the assemblies locally:
On the development machine, copy whichever PowerCLI .dlls you reference from the GAC (in %WINDIR%\assembly) to your solutions local directory.
Change your references in the project to point to the local versions of the .dlls.
Open the 'Properties' view for each of the references, and make sure 'Copy Local' is set to True.
Compile and deploy your console application (and it's coresident .dlls) to the target machine, it should reference them in the local directory and run without external dependencies.
Hope that helps!
You could also automate PowerCLI installation with a silent installation one-line Powershell script, if the problem is hiding the installation from the users.
Invoke-Expression ("cmd /c '$powerCLIexeFilePath'/S /VADDLOCAL=ALL /V/qn")