I have added a Grunt task to my release pipeline. When the Grunt task runs, I get the following error:
Grunt-cli is not installed globally (or is not in the path of the user the agent is running as) and it is not in the local working folder:
C:\agent\_work\r9\a\node_modules\grunt-cli\bin\grunt
Any idea how to correct this error?
To ascertain whether grunt-cli is installed globally on your system run the following command via your CLI :
npm list -g grunt-cli
If it reports (empty) then install grunt-cli globally by running:
npm install -g grunt-cli
We ran into the same issue with our build pipeline on a (self-hosted) Agent...
I tried to install grunt-cli locally but it didn't work-out also.
After running the command npm list -g in script task, in yaml: - script: npm list -g, i found-out that the agent has another global folder, which should look like this (depending which user runs the azure pipelines agent service, for me was (local-system):
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm
So, i configured the grunt-task to search for the grunt-cli in the node_modules in that location. In yaml pipeline plan it looks like this:
# Need to run at the first build, then set enabled to false
- task: Npm#1
enabled: false
inputs:
command: 'custom'
customCommand: 'install -g grunt-cli'
- task: Grunt#0
displayName: Run Grunt tasks
inputs:
gruntFile: Gruntfile.js
gruntCli: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt'
I had to run the npm i -g grunt-cli in my pipeline to get grunt-cli installed globally for the agent.
Hopping that would be helpful!
Related
So I have a Typescript project called backend with a depedency like such in its package.json:
"dependencies": {
"#the-couple-game/helpers": "^1.0.0",
}
And helpers (also Typescript) is in another folder with its package.json like such:
{
"name": "#the-couple-game/helpers",
}
So running lerna bootstrap should link the two and install #the-couple-game/helpers in backend's node_modules which it does locally.
However, doing the same (with --no-ci because I don't want npm ci) using Codebuild using the below buildspec.yml does not add a #the-couple-game/helpers in backend's node_modules. So if I run backend's transpiled index.js it would complain about the missing module.
version: 0.1
phases:
install:
commands:
- npm install -g lerna
pre_build:
commands:
- lerna bootstrap --no-ci --concurrency 4
build:
commands:
- lerna run build --concurrency 4
artifacts:
files:
- "**/*"
For now, I have to resort to manually doing a lerna bootstrap after deployment to CodeDeploy (using a script called from appspec.yml) so it installs the missing module but shouldn't Codebuild have covered that part?
Thanks.
So it turns out AWS CodePipeline doesn't support symlinks in source (Codebuild in my case). Reference
So after deployment, I'll have to lerna link using a shell script to create the links which is not an expensive job for my micro ec2 instance to do.
my npm install -g is not working as intended. It installs the package I need, however the CLI commands which comes from the package is always absent.
One example is, I was following the quick start on TypeORM.
It says
First, install TypeORM globally:
npm install typeorm -g
Then go to the directory where you want to create a new project and run the command:
typeorm init --name MyProject --database mysql
but when I tried typeorm init --name MyProject --database mysql. I got the error -bash: typeorm: command not found I think it has something to do with my environment path setting.
This is the output from my echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/aria2/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/Postgres.app/Contents/Versions/latest/bin
Can someone help me with this?
OK I figured this out myself. Solution is here : https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
In Linux/Unix, if you are a normal user, i.e. not root, you cannot install global packages, as these packages are written to system folders. In your case, -g is doing nothing as it cannot access system folders, so it is installed locally as any other regular package. in order to fix your problem, you have to gain more privileges. To do so, you can run the command at the root level i.e:
sudo npm install typeorm -g
and then you can access it from anywhere as -g is intended to put it as global; no need to play with environment path settings as -g also take care of doing so.
if you need a bash session as full root (a root terminal, or in windows terms a cmd/powershell running as administrator) without really signing in to root account for security purpose, use:
sudo -i
and then do whatever you want as root without writing sudo everytime :D; as i said, this command opens the current terminal session as root, so you have to write it in each new opened terminal.
Hope it helps :D (It wiill actually ;))
To install package binary globally, npm needs to create links to /usr/local/bin, which may not happen if you don't give it permission. Try running with sudo.
$ sudo npm install typeorm -g
You can run
$ which typeorm
To check if it's installed properly.
You can use node version manager (nvm). But first uninstall your node.js.
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Then
command -v nvm
Then exit and open your terminal.
Then you can install any version of node.js.
For install the latest version type:
nvm install node
When the installation is complete install your package:
npm install typeorm -g
Then it should work correctly.
I think im a bit late but it might help someone :D
sudo npm install typeorm -g --unsafe-perm
I try to deploy my angular application on firebase using gitlab pipeline.
I followed this guide and I write a gitlab-ci file more simplified for starting.
image: node:latest
cache:
paths:
- node-modules/
stages:
- deploy
deploy:
stage: deploy
environment:
name: development
script:
- npm install -g firebase-tools
- npm install
- npm run builddev
- npm run deploy
only:
- master
Everything work until last command when I have this error
but if from terminal I run
firebase deploy --project test-1c121
everything work fine
Check your package.json file in scripts section. You probably have a typo in deploy because npm runs into problem with running firebse command and you want to run firebase.
I have the problem with Grunt on Virtual Hosting without Admin right.
On my computer I install and run Grunt by the Command Prompt (open site directory by the "cd" press enter and then run commands like npm install grunt ...), but on the hosting there is an option named "Crontab" which makes same as Command Prompt, but "Crontab" has only one input field where will be typed the command and than system will run that.
So the question: How to open site directory and there run grunt command only by one line code?
Like cd ~/my_site/public_html ; npm install but this doesn't work (I tried).
You can install the grunt-cli in local and run this local copy:
1) Install the grunt-cli locally : npm install grunt-cli --save-dev
2) Run the grunt cli (path can differ a little whether you're on Windows/Linux/Mac OS X) :
./node_modules/grunt-cli/bin/grunt my-task
This would be just like doing grunt my-task (but you're not using the global grunt-cli, but the local one, so no admin right needed).
I was following yeoman tutorial http://yeoman.io/codelab/prepare-production.html and everything worked fine until I tried to launch my project with "grunt" command then I got the following error:
Running "autoprefixer:dist" (autoprefixer) taskAutoprefixer's process() method is deprecated and will removed in next major release. Use postcss([autoprefixer]).process() insteadFile .tmp/styles/main.css created.
jit-grunt: Plugin for the "ngtemplates" task not found.If you have installed the plugin already, please setting the static mapping.See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "ngtemplates" failed. Use --force to continue.
Aborted due to warnings.
I use Linux Mint 17
A workaround was posted at the generator-angular github. Try modifying your Gruntfile.js to make the jit-grunt block look like this:
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
ngtemplates: 'grunt-angular-templates',
cdnify: 'grunt-google-cdn'
});
This is a issue for grunt-autoprefixer which is deprecated.
I am guessing, you installed a old version of generator-angular and current version of grunt which is written in the tutorial with following commands.
npm install --global yo bower grunt-cli
npm install --global generator-angular#0.11.1
It is better to install the current version of generator-angular. Just run this and start over again.
npm install -g generator-angular