I have a Grunt task called eslint:jenkins that runs eslint on the project. In the build pipeline I run it as:
grunt eslint:jenkins --force --verbose
I use --force so the grunt will not fail even if the task fails because there are some eslint issues.
When I run this locally everything is fine. When this runs on Jenkins I get the following error:
<path-to-installation>/Node_10/bin/node: bad option: --force
For both local and Jenkins environments the versions are: Node 10.0 and grunt-cli 1.3.1.
I cannot imagine any reason why in one case the --force flag is propagated to Node. Can anybody give me some pointers on where to look at?
Same issue with node 10 and a gulp task with arguments.
./node_modules/.bin/gulp tasks:my-task --myoption=value
[16:14:24] Node flags detected: --myoption=value
[16:14:24] Respawned to PID: 21231
No issue with node 8. Did not try with node 9. There must have been a breaking change somewhere, but I can find any information on this beside this question and https://github.com/gulpjs/gulp/issues/1564
sudo npm install grunt-cli -g
Should output something like:
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli#1.3.2
updated 2 packages in 3.056s
Then grunt --force should work for you.
(Tested on macOS Mojave)
Try using
grunt tasks:my-task -myoption=value, it worked for me.
Related
Note: I am on Windows 10 64 bit running the latest LTS Node build.
It all started when I tried running the command npm i -g create-react-app and I get a message saying that npm is not a command.
I checked my PATH and I believe I have the proper directories in there.
I navigated to the directory of npm and tried running the command again, but it still didn't work. I found that the command npm.cmd worked in any directory. So tried running npm.cmd i -g create-react-app and that worked! I also had to use the the command create-react-app.cmd my-app, instead of create-react-app my-app. I thought I was set and I could just use those .cmd commands for the things I needed to do; however, when I tried to run the command create-react-app.cmd my-app and got this as a result:
I have looked in the file that is ran when using this command create-react-app.cmd my-app and there is no sign of npm being called. Turns out Node is being called in that file with the command below. I know this because when I run it by itself and I get the same output to the console seen in the previous image.
"node" "C:\Users\Allen\AppData\Roaming\npm\\node_modules\create-react-app\index.js" my-app
it was called in the create-react-app.cmd file like this "%_prog%" "%dp0%\node_modules\create-react-app\index.js" %*
I am at a loss. I could continue down this rabbit hole and try and find the node file that is calling npm and change it to npm.cmd but I would rather find a way to get the npm and create-react-app commands working as they are suppose to. At the very least I can just spin up a VM and work in that. It is just annoying that I can't get Node to work properly for me.
Use the command npx create-react-app my-app this will help you create react projects.
Also check the documentation : https://reactjs.org/
First check that you have npm installed on your machine and the version. You can just type npm version. Since npm version 5.2.0 npx is pre-bundled with npm, which is a CLI tool whose purpose is to make it easy to install and manage dependencies hosted in the npm registry. So try using npx create-react-app app-name. You can confirm that you are able to use npx by running which npx. If it is not available then you can install it by running npm install -g npx.
I have followed this link to try to install a mean.js stack on an ubuntu server.
Regarding grunt, in /opt/mean, I have done
sudo npm install -g bower grunt-cli
sudo npm install grunt --save-dev
sudo npm install
However, grunt or grunt jshint inside the folder gives
A valid Gruntfile could not be found. Please see the getting started
guide for more information on how to configure grunt:
http://gruntjs.com/getting-started
Fatal error: Unable to find Gruntfile.
Note that npm start works, and http://server_domain_or_IP:3000 can display the sample application.
Does anyone know how to fix the grunt error?
As the error states, you do not have a Gruntfile and https://gruntjs.com/getting-started shows you an example of one.
Simply installing Grunt is not enough. When you run grunt it needs a configuration file (your Gruntfile) to run any tasks. The Gruntfile itself contains the tasks to be run.
You will need a Gruntfile.js in your project. you can create the same using the following grunt command.
grunt-init gruntfile
The above command will create the sample gruntfile.js file in your project.
The application I want to implement continuous deployment on Bamboo has node modules and bower component dependencies. On the bamboo server nodejs, npm have been installed.
There are only three tasks on default job:
Source Code Checkout
Build dependencies:
npm install
bower install
Deploy to the staging server
The problem is on the second task, bamboo fails with the message "No failed tests found, a possible compilation error occurred." I don't even run any tests.
The log file is not explanatory at all:
Starting task 'Build dependencies' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
Failing task since return code of [/bin/sh /home/ubuntu/bamboo-installation/temp/WEB-WEB-JOB1-8-ScriptBuildTask-4430338079602360707.sh] was 1 while expected 0
Ok, I solved the problem. The issue was the wrong node (which obviously messed things up) was installed on the bamboo server. Uninstalled the wrong one and everything worked as expected.
Good to see you solved it.
There is a setup I use and which could prevent further problems with CI:
export npm_config_prefix=.npm/
export PATH=.npm/bin:$PATH
export CI=true
npm install -g bower
bower install
npm install
This installs bower (and others like grunt-cli if you want) in your project folder so you can e.g. have a specific version, sets CI=true as advised in bower docs, and then installs all dependencies.
Bamboo AMI originally have npm version 1.4.28 installed and you are probably using a more recent version on you development environment. I had the same issue and resolved it by creating a script task to update npm version on the very beginning of my build process. Here is the script:
# update npm
curl -O -L https://npmjs.org/install.sh
chmod +x install.sh
sudo PATH=$PATH:/opt/node-0.10/bin ./install.sh
I'm new to command line and yeoman, but it's something I have been too to explore and decided to follow the introduction into getting started with a Yeoman webapp.
I made sure my Ruby, Compass, Git and NodeJS were all installed before installing Yeoman.
I successfully installed Yeoman and the Generator-webapp.
Then I ran yo webapp in a directory and pulled down a webapp with Bootstrap, Sass and Modernizr.
However it doesn't appear to have created a bower_components for my dependancies, because when I run ls this is what I see
Andrew-Clarks-MacBook:project1 clk$ ls
Gruntfile.js app bower.json node_modules package.json
Then when I run grunt serve i get the following errors
Andrew-Clarks-MacBook:project1 clk$ grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "concurrent:server" (concurrent) task
Running "copy:styles" (copy) task
Done, without errors.
Execution Time (2014-04-18 04:28:49 UTC)
loading tasks 4ms ▇▇▇▇▇▇▇▇▇▇▇ 22%
copy:styles 13ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 72%
Total 18ms
Warning: Syntax error: File to import not found or unreadable: ../../bower_components/bootstrap-sass-official/vendor/assets/stylesheets/bootstrap.scss.
Load paths:
/Users/clk/Sites/project1
/Users/clk/Sites/project1/app/styles
/Users/clk/Sites/project1/bower_components
on line 4 of app/styles/main.scss
Use --trace for backtrace. Use --force to continue.
Aborted due to warnings.
Execution Time (2014-04-18 04:28:46 UTC)
concurrent:server 4.2s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100%
Total 4.2s
When I run bower install to try and get them I get the following message
Andrew-Clarks-MacBook:project1 clk$ bower install
bower jquery#~1.11.0 not-cached git://github.com/jquery/jquery.git#~1.11.0
bower jquery#~1.11.0 resolve git://github.com/jquery/jquery.git#~1.11.0
bower modernizr#~2.6.2 not-cached git://github.com/Modernizr/Modernizr.git#~2.6.2
bower modernizr#~2.6.2 resolve git://github.com/Modernizr/Modernizr.git#~2.6.2
bower bootstrap-sass-official#~3.1.0 not-cached git://github.com/twbs/bootstrap-sass.git#~3.1.0
bower bootstrap-sass-official#~3.1.0 resolve git://github.com/twbs/bootstrap-sass.git#~3.1.0
bower jquery#~1.11.0 ENORESTARGET No tag found that was able to satisfy ~1.11.0
Additional error details:
No versions found in git://github.com/jquery/jquery.git
If someone can help this command line / yeoman rookie (and i mean rookie) that would be fantastic.
Apologies if this query has come up before, I searched for a fair while before posting!
Go into your main.scss file, and on line 4, change the ../../ part to just ../
The the bower_components file is found under app/bower_components.
../ takes you up one level from the directory that main.scss is in, which is in this case is app/styles.
../../ takes you up two levels, when you only need to go up one.
Not sure why when you run yo webapp it does that, I had the same problem. It must be to do with a the new update.
I had a problem with the missing bower components folder and I changed from using the npm command line to GIT bash and then everything seems to work fine.
I had the same problem, everything was installed except the bower_components folder in the app folder.
Untill I used GitBash instead of cmd, and it worked like a charm!
Folks, i faced the same issue [ and am not familiar with GitBash] , but i managed to resolve it after i followed bower install procedure to manage third party dependencies. More help here https://github.com/yeoman/generator-webapp
There was an issue with webapp that looks to have been resolved in newer versions.
webapp - relative references.
Also, you can check to see if you have bower installed:
bower -v
If it is not installed then install it:
npm install -g bower
In my Jenkins job I want to build a JavaScript app using Grunt. The Jenkins build scripts creates a build directory (if it doesn't already exist), changes to that directory and runs:
npm install grunt
npm install grunt-zip
grunt --gruntfile=[something]
(Of course grunt-cli is installed globally.) When I build the job, the first statement causes Grunt and dependencies to be pulled down as expected. However, the job then terminates successfully:
Archiving artifacts
No emails were triggered.
Finished: SUCCESS
The second npm install is not run. Any idea why the script is terminating after running npm install instead of continuing to the subsequent statements?
So it turns out that npm is a batch file, not an executable, so it needs to be invoked using call from the Jenkins script:
call npm install grunt
i would recommend not using the local grunt / nodejs install, but instead getting jenkins to do this for you!
it's much easier and means there's less coupling to system specific installs and variables.
steps:
a) use nodejs jenkins plugin + get it to install nodejs on machine/grunt-cli -> Jenkins integration with Grunt
b) populate your package.json with any nodejs dependances required, eg grunt/grunt-zip etc
c) when running grunt just do a "npm update" before "grunt" command
that way your not doing explicit npm install, it's all configured from your package.json, and your build scripts will be less brittle, and your developers can use the same steps as the build server, eg "npm update;grunt" locally same as build server
For future googlers:
use command chaining for this.
This works:
npm install && npm install install grunt-zip
This wont work:
npm install
npm install grunt-zip