I use the Apt buildpack to install tesseract.
Now I need to copy a config file into a directory
that only exists after the tesseract installation.
Where can I put something like "mv configfile destination"
that gets executed after the tesseract installation?
This should happen automatically during a deploy and
not manually after the fact.
Thanks
Andre
We use the NPM postinstall hook to perform build tasks, load dev dependencies for those tasks, cleanup, etc.
From the scripts section of your package.json:
"scripts": {
"postinstall": "node ./ops/heroku-build.js"
}
In that file you can use fs to copy the file, and do any other tasks that need to be accomplished.
https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process
Related
Could you please give me some advise on how to deal with this issue.
Build Pipeline
npm install
package.json
"dependencies": {
"cypress": "^3.4.1"
}
Release
Powershell command
npm ./node_modules/.bin/Cypress run
The cypress npm package is installed, but the Cypress binary is missing.
2019-10-07T18:04:59.5720120Z We expected the binary to be installed here:
There are some examples on how to cache ~/.npm but nothing seems to work so far. Examples on how to include cypress.io in your vsts are at the building stage and not after release.
According to the error log, it has provided a solution about this. You should run the cypress install command first and then the error will be fixed.
As my test, since I don't have a cypress.json file, so I need run the open command to
automatic generated get the json file and project sample.
Then the open command run as expected.
But because I run the open command in interactive mode and I don't have the cypress.json file in my artifacts, the taks finally failed.
So if you have cypress.json in your repo or artifacts, you just need to add
.\cypress install
in your powershell command.
And if not, you can add the related json file and folder to your repo or artifacts and then the run command will work as your expected.
I tried editing inside node_modules but the files are taken from dist and src seems to be ignored.
I tried npm run build to see if I can push my changes to dist but that doesn't work either as other dependencies seem to be missing.
UPDATE:
I followed the instructions about set up dev env in the Contributing section of the docs.
Made the changes and did yarn and yarn build
But the dist folder is identical to the one without my changes
What gives?
Instructions in the set up dev env in the Contributing section work.
After running "yarn build" in the cloned repository folder, you can copy the contents of the dist folder under packages/vuetify to the dist folder under node_modules/vuetify of the app being developed and your changes can be tested.
You can also do npm run build inside packages/vuetify for subsequent changes.
You can edit code in node_modules/vuetify/lib/components/VSlider/VSlider.js
Then, you install patch-package and execute path package vuetify
Delete node modules and execute yarn to create new node modules
Last, yarn serve, you see your code is work
https://www.npmjs.com/package/patch-package
I used aurelia-cli to setup my Aurelia application on top of the backend in asp.net WebAPI.
I run backend from visual studio on a port in localhost, which exposes the api endpoints. Then I open git bash from my project directory to do au run which runs my Aurelia frontend on localhost:9000
On Visual Studio online, it builds my backend project even if I made a change to one of the typescript files within Aurelia. But the artifact created by build process doesn’t have any .ts files. This is similar to if I were to publish from visual studio.
To publish Aurelia, I do au build -–env prod separately on git bash from project directory, that bundles files into app-bundle.js and vendor-bundle.js inside wwwroot/scripts directory.
So I have two different projects for Aurelia and webAPI. The question is can I build both together in visual studio online/TFS?
I tried adding a shell script with the au build –-env prod command as a task to my build process. It tried to run from the temp location where it drops the artifacts eg: d:\a\1\s\mycommand.sh . Aurelia isn’t installed there, so I got au command not found error.
If not together, can I run the aurelia project separately from vs online so I get the bundled js files that I can then use to deploy, without having to run the commands from git bash?
Update: after writing this post, I got this post in suggestion How to optimize workflow with single project using Aurelia CLI / ASP.NET Core
which mentions "the au build command is executed in the precompilation target, so when I build or run the ASP.NET Core project from Visual Studio using F5, Aurelia CLI will build and bundle the assets for the Aurelia app into wwwroot as well."
It doesn't say how to do it, that is what I'm trying to achieve. Perhaps asking question as an answer is not advised so I asked it here.
There are many ways that can call au command:
Install Aurelia cli in a folder:
Include aurelia-cli package dependence in package.json file (dependencies or devDependencies) or install it directly through Command line task (Put package.json file in the target folder that you want to call au command)
Add au build command to scripts of package.json
Sample:
{
"name": "autest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"aurelia-cli": "^0.32.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"aubuild": "au build --env stage"
},
"author": "",
"license": "ISC"
}
Install package through NPM build task (Command: install; Working folder with package.json: package.json folder path)
(Option 1) Call NPM command through NPM build task (Command: custom; Working folder with package.json: package.json folder path; Command and arguments: run aubuild)
(Option 2) Call au command through Command Line task (Working folder: Aurelia-cli package installed path; Tool: node_module\.bin\au; Arguments: build --env stage)
Install Aurelia cli in global:
Add command line task (Tool: npm; Arguments: install aurelia-cli -g)
Call au command in any folder
Regarding "the au build command is executed in the precompilation target”, you can try to build the project through Visual Studio task and check the result.
I would like to have Heroku build my app after I push it so that I don't have to push the build folder up every time I make a change. However Heroku only installs the dependencies from the package.json and grunt (my build tool) and all of its components are in devDependencies. I would like to keep them there where they belong. What's the workaround here?
UPDATE: as pointed out in the comments this is no more needed because since 2018 heroku changed its default behaviour and dev dependencies are automatically installed
ORIGINAL ANSWER
Heroku by default installs only the production dependencies, ignoring the development dependencies under devDependencies.
Setting the npm production variable to false do the trick:
heroku config:set NPM_CONFIG_PRODUCTION=false
More info are available at the Heroku Node.js Support page.
Keeping NPM_CONFIG_PRODUCTION true, I used Heroku's script hooks:
"scripts": {
...
"heroku-prebuild": "export NPM_CONFIG_PRODUCTION=false; export NODE_ENV=; NPM_CONFIG_PRODUCTION=false NODE_ENV=development npm install --only=dev --dev",
"heroku-postbuild": "export NPM_CONFIG_PRODUCTION=true; export NODE_ENV=production;",
...
},
(Finally) worked for me.
scripts": {
...
"heroku-prebuild": "npm install --only=dev"
}
This was enough for me. Thanks to PixnBits for the hint about heroku-prebuild.
Also - my problem was with babel. I ended up moving babel-preset-es2015 and other presets into dependencies otherwise babel complained about presets.
Update: 8/11/2017 I've been having trouble with this. It seems like things have changed (and npm is on 5.3 now). But what I see is that the heroku-prebuild script is getting run, and then the post-install script is getting run (but I was only trying to install -dev).
So what I have been doing that works is to just run:
heroku config:set NPM_CONFIG_PRODUCTION=false
And just leave it set that way. I'd love a better solution.
you can use this in your build script "build": "npm install --only=dev" should in case you still want to perform more operations e.g transpiling your code with babel you can do something like this "build": "npm install --only=dev && babel src --out-dir dist --copy-files"
To unintall dependencies you need to do these
Update NPM_CONFIG_PRODUCTION
heroku config variable set
NPM_CONFIG_PRODUCTION=false
Add heroku-prebuild:
scripts": {
...
"heroku-prebuild": "npm install"
}
or
scripts": {
...
"heroku-prebuild": "npm install --only=dev"
}
Since 1 March 2018 Heroku installs devDependencies by default, and then prunes them after the build step is done:
By default, Heroku will install all dependencies listed in
package.json under dependencies and devDependencies.
After running the installation and build steps Heroku will strip out
the packages declared under devDependencies before deploying the
application.
Heroku uses the lockfiles, either the package-lock.json or yarn.lock,
to install the expected dependency tree, so be sure to check those
files into git to ensure the same dependency versions across
environments.
Link
I found this highly confusing. Even though Heroku says that their default since 2018 is to install all dependencies, they also set the env var NODE_ENV=production by default. This is good because it causes/allows for pruning, but it is bad because it means NPM will not install devDependencies.
To avoid this without messing with environment variables and their possible side effects, we can append --production=false to npm and it will install dependencies and devDependencies.
In our case, in package.json in scripts we have a line:
"install": "npm i --prefix ... --production=false"
My answer similar to others above with the additional references that seem to explain why it's not actually working by default like Heroku suggests.
I'm trying to automate building of my project on a TeamCity server. I'm using grunt to define and configure my tasks. This works fine locally. Yet, I am having problems getting TeamCity (running on Windows Server 2008) to recognize grunt as a executable, the build will fail when grunt is called as it is not available.
I do have grunt-cli installed on the server and can execute it when I login via ssh (The build script also succeeds when I trigger it that way).
I'm running npm install before I call grunt and also tried to force install grunt-cli using a preinstall instruction in my package.json like:
{
"name": "someName",
"version": "0.0.1",
"private": true,
"scripts" : {
"preinstall" : "npm install grunt-cli -g"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-less": "~0.8.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-strip": "~0.2.1",
"grunt-bump": "0.0.11"
}
}
I can see npm installing grunt-cli, yet grunt is not available in the next step.
I also tried wrapping that into a bat file or using multiple build steps for dependency installing and running the grunt task.
Does anyone have any input on this?
I had the same problem when trying to get our TFS Build agents to run grunt-cli. In the end I just changed my build process to use the full path to the grunt-cli executable.
So I changed from using this:
grunt deploy
to using this:
"C:\Users\tfsservice\AppData\Roaming\npm\grunt.cmd" deploy
I know this is just a workaround and not a true fix, but it should be good enough to get you going. I hope this helps.
-- Update --
I was able to get it to work properly by simply adding "C:\Users\tfsservice\AppData\Roaming\npm" (where the grunt.cmd file is found) to my system path, and then rebooting my build server. The reboot was required since tfsservice is both a user and a running service; simply restarting the service may be enough, but I didn't test that.
After doing this grunt deploy worked in our builds as expected.
You are running Teamcity agent on Widnows Server?
There is plugin for Node.js/Grunt for Teamcity: https://github.com/jonnyzzz/TeamCity.Node
As far as I've used it had no issue running grunt with Teamcity.