I'm trying to use gulp on w7. gruntjs works .. node works ...
If i start gulp without gulp file, it runs fine .. saying 'no gulpfile found'
gulp -v gives: cli version 3.5.6, local version 3.5.6
installed it using:
npm install -g gulp
npm install --save-dev gulp
If I use the following gulpfile:
var gulp = require('gulp');
It results in error dialog:
Windows Script Host
Line 1
Char 1
Object Expected
800A138F
Microsoft JScript runtime error
I did try a more lengthy gulp file, but same error ... by deleting lines, I tried to isolate the problem .. until the file was empty .. that was ok.
Any ideas?
Here are steps I used to solve that issue:
if your tasks file is gulp.js, rename it to gulpfile.js
Install gulp globally > npm install -g gulp
Test installation > gulp -v
You are good if you can see the version number of your gulp task runner!
If you're getting a Microsoft JScript runtime error it isn't running in node but rather in Windows Scripting Host. Ensure Node.exe is in your PATH.
Related
I've been trying to install Semantic UI with npm. The website says to run the following code:
npm install -g gulp
npm install semantic-ui --save
cd semantic/
gulp build
Gulp seems to install correctly, as does Semantic UI. But when I run the last line, I get
No gulpfile found
I'm not sure what this could be from. Do I need to make a file before I run this command?
Thanks!
Run gulp build from inside of /semantic (not root)
Gulp is looking for a gulpfile in the same directory where the command is executed.
So, cd into the semantic directory and try running gulp build again. It should work as long as you see a gulpfile.js file and have followed all the steps from the Gulp quick start.
I am new to gulp and I am facing problem in integrating it with msbuild. I am trying to run tasks using gulp(e.g: minifying files) and even though it works perfectly when I build my project,it fails to run on msbuild.
Here is the code for gulpfile.js:
var gulp=require("gulp"),
gutil=require("gulp-util"),
uglify=require("gulp-uglify"),
debug=require("gulp-debug"),
concat=require("gulp-concat");
var uglifycss = require('gulp-uglifycss');
gulp.task("js",function(){
gulp.src(["./**/*.js","!./**/*.min.*","!./**/gulpfile.js"])
.pipe(uglify())
.pipe(debug())
.pipe(gulp.dest(function(file){return file.base}));
gulp.task('css', function () {
gulp.src(["./**/*.css","!./**/*.min.*"])
.pipe(uglifycss())
.pipe(gulp.dest(function(file){return file.base}));
});
gulp.task("build",["js","css"]);
gulp.task('default', function(){
gulp.run('build');
});
this is called by a powershell script file compileClient.ps1:
npm install -g gulp
npm install --save-dev gulp gulp-util
npm install --save-dev gulp-uglify gulp-concat
npm install --save gulp-uglifycss
npm install --save-dev gulp-debug
gulp
npm install -g rimraf
cmd /c $env:APPDATA\npm\rimraf ./node_modules
when I run this command on cmd,
"%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe" -file "$(ProjectDir)compileClient.ps1"
It works fine and minifies the target files. I then tried putting this command in the post build event of my project and when I run it locally on visual studio it works fine too.
however when this project is built by msbuild, the same post-build event does not work,it gives the following message shown in the image below:
npm : the term 'npm' is not recognized as the name of a cmdlet..
I checked the PATH variable set by node and it is correct. Also when I do node -v on my cmd I could see the version of node installed, but when I do it on the msbuild command line it fails to identify node.
I used this blog as a reference
https://www.niclassahlin.com/2015/04/10/running-gulp-during-tfs-build/
I would appreciate any help/advice on this matter, thanks.
You can use Node.js installer to install npm, npm will be available for all users after this.
So I am trying to run gulp on our build server but keep getting the error above. Everything works fine if I log into the build server with my user account as I installed gulp globally under my account however when Jenkins runs my powershell script it fails with the error:
The term 'gulp' is not recognized as the name of a cmdlet error
So I tried to install globally in my script so that it installs with whatever user Jenkins uses.
Then I added npm -g ls to The powershell script and found that it is installed globally under a system user:
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm >
gulp#3.9.0
Since I am still getting the error I took the advice from this post and added a path variable with the directory above however still the same error.
Anyone have ideas on what I can try next? Im stumped as to why it is not working.
Make sure the directory containing gulp.exe is contained in the $env:PATH environment variable. You can update the machine-wide PATH variable with the [Environment]::SetEnvironmentVariable() method.
Let's imagine the path to the gulp executable is C:\Program Files\gulp\bin\gulp.exe
# Directory containing exe
$GulpFolderPath = 'C:\program files\gulp\bin'
# Retrieve user-agnostic PATH environment variable value
$CurrentEnvPath = [Environment]::GetEnvironmentVariable('PATH','Machine')
# Check if PATH already contains gulp
if($CurrentEnvPath -split ';' -notcontains $GulpFolderPath)
{
# if not, update it
$NewEnvPath = $CurrentEnvPath,$GulpFolderPath -join ';'
[Environment]::SetEnvironmentVariable('PATH',$NewEnvPath,'Machine')
}
Finally a true GULP solution
After having searched for a solution the past two days without success, a colleague assisted me by running the following commands, the first installs gulp locally and globally and the second which I attribute the success for gulp finally running, installs the angular cli globally:
npm i -g gulp gulp
npm i #angular/cli -g
Afterwards I ran this command to update npm packages globally and locally; gulp finally worked:
npm install -g npm
Now running gulp -v yields success:
CLI version: 2.2.0
Local version: 4.0.2
NB: My OS is Windows 10 64 bit architecture latest updates on the 17th of July 2019. No proxy settings, no network ristrictions!!
If you do have a proxy before the internet configure your .npmrc file found by running the command npm config edit from your command line application:
proxy=x.x.x.x:PORT/
https-proxy=x.x.x.x:PORT/
prefix=C:\npm\node_modules
cache=C:\npm\cache
I am new to nodejs and gulp stuff. I working on a nodejs project in which I have to run jslint on all the files. I am using gulp for this purpose.
My problem is that In order to run gulp on cli I don't want to install gulp globally and also does not want to update my path variable, So I have installed gulp and other node modules in my project locally using the package.json file
cd myproject
npm install
Since I don't want to install gulp globally and want to run the local gulp I have added script in my package.json file like this as given in this question
{
"name": "",
"version": "1.0.0",
"main": "index.js",
"private": true,
"dependencies": {
"async": "1.5.0"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-jslint": "^0.2.2"
},
"scripts": {
"gulp": "./node_modules/.bin/gulp" // is this correct?
}
}
Add added a gulpfile.js inside my myproject folder
var gulp = require('gulp');
// include plug-ins
var jslint = require('gulp-jslint');
// JS hint task
gulp.task('lint', function() {
gulp.src('./common/srp/*.js')
.pipe(jslint())
.pipe(jslint.reporter('default'));
});
gulp.task("default", ["lint"]);
But now on my command line inside myproject folder, when I run gulp and gulp lint I get an error
user1-VirtualBox:~/myproject$ gulp lint
/usr/local/node-v0.10.26-linux-x64/bin/gulp No such file or
directory
Its looking for gulp in the global node module.
Is there a way to make gulp run on cli without installing globally and updating PATH variable.
Any help will be appreciated
Thanks
You can find any executable installed by npm in node_modules/.bin. So you can run gulp locally using:
./node_modules/.bin/gulp
You can find more information at no command 'gulp' found - after installation
With your code you should be able to run command
npm run gulp
Please try
One way to define script is
"scripts": {
"gulp": "gulp"
}
If in case you are not able to run gulp command in your project, run
npm link gulp
It will link your global install gulp with your local project. Then try
gulp -v
If it is showing you the version then you are done. Now you can run any gulp command as you want.
Scripts defined in package.json are accessed through NPM, i.e. npm run-script gulp. I imagine you're trying to run plain old gulp, which should fail since you didn't install it globally.
The scripts section won't automatically create an alias, which I think is your mistake here. You could define one yourself or create a simple bash script if you don't want to type it every time.
Try:
path_to_node path_to_gulp_js gulp_task
Example:
node\node.exe node_modules\gulp\bin\gulp.js build
Like #snorberhuis said. The only way for me to get gulp to work globally was to call gulp manually
I am building in a Jenkins environment
Execute Windows Batch Command
cd your-app
npm install gulp
Execute Windows Batch Command
cd your-app\node_modules\.bin
gulp
Just another alternative that will work locally but will give you global like feeling.
Add to your shell config i.e. ~/.bash_profile the following
export PATH=$PATH:./node_modules/.bin
you have to source that file, execute rehash or just open a new shell and then gulp (and any other script inside that folder) shall be available as a global command.
The way I did this after bashing my head every possible place is simply going to your Application and install npm dependencies like this:
1- E:\webra-jenkins\Code\trunk\WebRa.Web>npm install
Once npm installed then go this directory
2- [%Application_path%]\node_modules\.bin
And execute the gulp and give your file/task, like this:
3-[%Application_path%]\node_modules\.bin>gulp gulpfile --tasks
In my case as I saw the following lines... I got the inner happiness
18:06:36] Working directory changed to [%Application_path%]
[18:06:37] Tasks for [%Application_path%]\gulpfile.js
Now you can run your tasks 1 by one.
[%Application_path%]\node_modules\.bin>gulp pack-vendor-js
Check in your project node_modules/.bin folder and make sure gulp is in there. I had a case where it wasn't there that I never tracked down the reason for. If it isn't there, try re-installing gulp locally and see if it shows up. If that doesn't work and you get tired of the problem, the gulp-cli package will fix it for sure, but that shouldn't be something you have to do.
The simplest solution I know of is to use npm bin:
`npm bin`/gulp ...
This keeps you away from hard-coding any paths.
Nothing was working for me. I followed all instructions from everyone. No matter what I did I could not run the Gulp commands.
To fix this I opened the Node.js command prompt that comes installed automatically when you download and run node.js.
Once I was in this command prompt I could run the following commands:
npm install -g gulp
gulp -v
This is probably a matter of common knowledge but as someone starting out no one suggested to run the node.js command prompt and install gulp from there. Everything I read talked about regular powershell or command prompts with elevated permissions.
Globally install gulp in C:\Users\%USERNAME% using this command
npm install –g gulp
You can install any other gulp methods you need to use.. Ex:
npm install -g gulp-concat
npm install -g gulp-uglify
npm install -g gulp-replace
Then at the directory you wish to use GULP. Open the command prompt (Shift + RightClick) then install locally and you'll be able to execute gulp.
npm install gulp
You can install any other gulp methods you need to use.. Ex:
npm install gulp-concat
npm install gulp-uglify
npm install gulp-replace
I've project to join so I cloned repo from git. I have installed npm install and then bower install, but when I try to run the app with grunt serve command, console returns this:
Loading "cdnify.js" tasks...ERROR
>> Error: Cannot find module 'chalk'
Running "serve" task
Running "clean:server" (clean) task
Running "wiredep:app" (wiredep) task
Warning: ENOENT, no such file or directory '/home/tomek/dev/mobilas/app/bower.json' Use --force to continue.
Aborted due to warnings.
The thing is, I shouldn't really change neither Gruntfile.js nor bower.json file.
Link I referenced in comment above fixed it for me... just had to run
npm install chalk
in the project directory as a work around until they get one of the grunt dependencies fixed.
Running below commands should fix your errors...
$cd /home/tomek/dev/mobilas
$rm -rf node_modules
$npm install
Now you should be able to run your app with $grunt serve command