Sublime Text 3 and sublime-grunt-build - node.js

So i have an error, while i try to build, there is commandline which says:
grunt-cli: The grunt command line interface. (v0.1.13)
[Finished in 0.1s with exit code 99]
[cmd: ['grunt.cmd', '--no-color']]
[dir: F:\LavkaLavka\Shop]
[path: C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\PROGRA~1\SOFTWARE\System\DISKEE~1\;C:\Program Files (x86)\SOFTWARE\Players\Quick time\QTSystem\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\SOFTWARE\Design\NodeJS\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\SOFTWARE\Coders\MP4BOX;C:\Users\133\AppData\Roaming\npm]
So i have installed node.js with npm, then installed globally:
grunt
less
grunt-cli
grunt-less
grunt-contrib-concat
grunt-contrib-less
Then in sublime i've unpacked latest zip of ssublime-grunt-build here:
C:\Users\133\AppData\Roaming\Sublime Text 3\Packages\sublime-grunt-build
I have simple Sublime text 3 project file in core project folder with only this base folder:
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"build_on_save": 1
}
}
with package.json:
{
"name": "133",
"description": "This is only a test.",
"version": "1.0.0",
"keywords": [
"css",
"less",
"mobile-first",
"responsive",
"front-end",
"framework",
"web"
],
"author": "133",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-cli": "~0.1.13",
"grunt-contrib-concat": "~0.5.1",
"grunt-contrib-less": "~1.0.0",
},
"engines": {
"node": "~0.12"
}
}
and Gruntfile.js:
module.exports = function(grunt) {
"use strict";
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * 133 v<%= pkg.version %>\n' +
' */\n',
// Task configuration.
concat: {
options: {
banner: '<%= banner %>',
stripBanners: false
},
dist: {
src: [
'js/133/transition.js',
'js/133/alert.js',
'js/133/button.js',
'js/133/carousel.js',
'js/133/collapse.js',
'js/133/dropdown.js',
'js/133/modal.js',
'js/133/tooltip.js',
'js/133/popover.js',
'js/133/scrollspy.js',
'js/133/tab.js',
'js/133/affix.js'
],
dest: 'js/133.js'
},
},
less: {
compileCore: {
options: {
strictMath: true
},
src: 'css/style.less',
dest: 'css/style.css'
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['concat', 'less']);
};
I've used Bootstrap 3 js files for test purpose
What am i missing?
I couldn't successfully google for grunt-cli exit code 99
and there are no official info on that i suppose...
Please help :)

Ok, it seems that i missed point of installing grunt locally via cd to my directory and then: install grunt..Is there any way of using global grunt and plugin files, wihtout installing to local directory? It could be more handy in my case)

Related

Is 'El Capitan's' rootless breaking old grunt configs?

After migrating to El Capitan, it seems users are experiencing an issue with grunt installations, possibly related to the rootless changes of El Capitan. In particular, running the grunt --force command results in EPERM errors. The workflow is as follows:
Assuming npm has been installed, navigate to the grunt directory with package.json and gruntfile.js and invoke grunt:
grunt --force
Example Gruntfile.js file contents:
module.exports = function(grunt) {
// All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
// Configuration for concatenating files goes here.
dist: {
src: [
'../js/libs/owl.carousel.js',
'../js/libs/jquery.actual.js',
'../js/libs/chosen.jquery.js',
'../js/libs/jquery.parallax.js',
'../js/src/common.js'
],
dest: '../js/pro/global.js',
},
},
uglify: {
build: {
src: '../js/pro/global.js',
dest: '../js/pro/global.min.js',
},
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: '../img/src/',
src: ['**/*.{png,jpg,gif}'],
dest: '../img/pro/'
}]
}
},
compass: {
dev: {
options: {
sassDir: '../sass',
cssDir: '../css',
fontsDir: '../fonts',
imagesDir: '../img/',
images: '../img/',
javascriptsDir: '../js/pro',
//environment: 'development',
outputStyle: 'compressed',
relativeAssets: true,
httpPath: '.',
}
},
},
watch: {
scripts: {
files: ['../js/**/**.js'],
tasks: ['concat', 'uglify'],
options: {
spawn: true,
},
},
images: {
files: ['../img/src/**.{png,jpg,gif}'],
tasks: ['imagemin'],
options: {
spawn: true,
}
},
compass: {
files: ['../**/*.{scss,sass}'],
tasks: ['compass:dev'],
}
},
svgstore: {
defaults: {
options: {
prefix : 'icon-',
},
files: {
'../img/svg-defs.svg': ['../img/svg/*.svg']
}
}
},
});
// Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-svgstore');
// Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat', 'uglify', /*'imagemin',*/ 'compass', 'svgstore', 'watch']);
};
Example package.json file contents:
{
"name": "Call Me Maybe",
"version": "0.2.0",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-compass": "^1.0.4",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-imagemin": "^0.9.4",
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-uglify": "^0.9.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-svgstore": "^0.5.0"
}
}
The resulting EPERM errors are as follows:
Running "concat:dist" (concat) task
Warning: Unable to write "../js/pro/global.js" file (Error code: EPERM). Used --force, continuing.
Running "uglify:build" (uglify) task
Warning: Unable to write "../js/pro/global.min.js" file (Error code: EPERM). Used --force, continuing.
Running "compass:dev" (compass) task
Warning: Command failed: /bin/sh: compass: command not found. Used --force, continuing.
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
Running "svgstore:defaults" (svgstore) task
Warning: Unable to write "../img/svg-defs.svg" file (Error code: EPERM). Used --force, continuing.
Running "watch" task
Waiting...
Interestingly, Ruby and Compass are also installed, so it does align with the theory of the rootless unable to write to folders issues, but how can the dependency cores be moved elsewhere (i.e. /usr/local/bin) so this isn't an issue?
During the El Capitan Betas, some users suggested enabling root via terminal - though this seemingly no longer works, as the error persists and /usr/bin folder still doesn't allow for permission changes.
For those running into the same issue, I had to eliminate the use of binaries installed to the path: /usr/bin, and reinstall after updating the path /usr/local/bin. Ruby tended to be the primary culprit. Because I was struggling with locating all my ruby installs, I ended up installing rbenv to manage my ruby versions.
The following terminal commands may be helpful in identifying your problematic paths:
which ruby
gem environment
gem uninstall [insert gem name here]
[google how to set your paths to /usr/local/bin... (will be in a hidden file)]
gem install [insert gem name here]
Installing non-system software on /usr/bin is a bad move, and is now prohibited in El Capitan, and with good reason.
I am not familiar with grunt, but if you can get to use /usr/local/bin instead then probably everything works.

SublimeLinter: WARNING: jshint deactivated, cannot locate 'jshint'

This just happened completely randomly. All I did was restart Sublime and next I know I had to re-set the path to git.exe and SublimeLinter jshint is broken. I've removed and re-installed SublimeLinter and SublimLinter-jshint in various orders to try to fix it.
I also installed jshint globally with npm.
SublimeLinter default/user settings:
{
"default": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"mark_style": "outline",
"no_column_highlights_line": false,
"paths": {
"linux": [],
"osx": [],
"windows": ["C:\\Users\\x\\AppData\\Roaming\\npm\\node_modules\\jshint\\bin"]
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"python django": "python",
"html 5": "html",
"html (django)": "html",
"html (rails)": "html",
"php": "html"
},
"warning_color": "DDB700",
"wrap_find": true
}
}
console:
SublimeLinter: jshint linter loaded
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.sublimelinter
plugins loaded
SublimeLinter: debug mode: on
SublimeLinter: temp directory: c:\users\x\appdata\local\temp\SublimeLinter3
SublimeLinter: computed PATH from system:
C:\Users\x\AppData\Roaming\npm\node_modules\jshint\bin
C:\Program Files\Common Files\Microsoft Shared\Windows Live
C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\ThinkPad\Bluetooth Software\
C:\Program Files\ThinkPad\Bluetooth Software\syswow64
C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
C:\Program Files (x86)\Common Files\Lenovo
C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\
C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\
C:\Program Files (x86)\Lenovo\Access Connections\
C:\Program Files\Common Files\Lenovo
C:\Program Files (x86)\Lenovo\Client Security Solution
C:\Program Files\Lenovo\Client Security Solution
C:\Program Files (x86)\OpenLDAP\kfw\Binary
C:\Program Files (x86)\Windows Live\Shared
C:\Program Files\Microsoft\Web Platform Installer\
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\
C:\PROGRA~1\IBM\SQLLIB\BIN
C:\PROGRA~1\IBM\SQLLIB\FUNCTION
C:\Program Files\nodejs\
C:\Python27
SublimeLinter: WARNING: jshint deactivated, cannot locate 'jshint'
SublimeLinter: found existing HTML syntax, version 3
SublimeLinter: found existing Rails syntax, version 1
found 3 files for base name Main.sublime-menu
Package Control: Skipping automatic upgrade, last run at 2014-07-30 10:51:51, next run at 2014-07-30 11:51:51 or after
According to the SublimeLinter documentation, it requires you to have linter executables in your path.
Most linter plugins require you to install a linter binary or library
and configure your PATH so that SublimeLinter can find it. You must
follow the linter plugin’s installation instructions to successfully
use it.
Have you tried opening a terminal window and seeing what happens if you type jshint --version? You should see something like jshint v2.5.0 as a response if it's already in your path.
Also, if you're like me, and can't modify your Windows PATH variables due to workplace restrictions, you can add the path to the Default and User settings like I did here Comment on SublimeLinter. This worked for Sublime 3 build 3065.
{
"default": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"mark_style": "outline",
"no_column_highlights_line": false,
"paths": {
"linux": [],
"osx": [],
"windows": ["C:/Users/myUserName/AppData/Roaming/npm"]
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"python django": "python",
"html 5": "html",
"html (django)": "html",
"html (rails)": "html",
"php": "html"
},
"warning_color": "DDB700",
"wrap_find": true
}
}

How to write a grunt-shell task which works cross-platform?

I'm trying to write a grunt task which removes a directory and its contents.
Here is config file
{
"name": "lorem",
"homepage": "ipsum",
"version": "0.9.5",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-shell": "~0.5.0",
}
}
and grunt.js file
// Whole Gruntfile.js so far
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
shell: {
clean: {
command: 'rm dist -r',
options: { stdout: true, failOnError: true }
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell:clean']);
};
This probably work on linux, but what if the machine is windows or osx?
Is there any cross-platform solution to this?
Shell commands uses the system shell, which differs between OSes. If you want something cross-platform, just do it in JS. As for your use-case you could use grunt-contrib-clean, trash, or rimraf.

grunt bowercopy task not found

I can't figure out my configuration problem. When I try to run 'grunt bowercopy', I get this error message:
Warning: Task "bowercopy" not found. Use --force to continue.
If I run 'grunt jshint', jshint works fine.
Here is my package.json:
{
"name": "treblebull",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "~3.2.6",
"jade": "~0.31.2",
"underscore": "~1.5.2",
"pg": "~2.11.1"
},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-bowercopy": "~0.7.1",
"grunt-contrib-jshint": "~0.8.0",
"load-grunt-tasks": "~0.2.1"
}
}
and here is my gruntfile:
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['lib/**/*.js']
},
test: {
src: ['test/**/*.js']
}
},
bowercopy: {
options: {
clean: true
//srcPrefix: 'bower_components'
},
libs: {
options: {
// destPrefix: 'public/js/lib'
},
files: {
'angular.js': 'angular/angular.js'
//'underscore.js': 'underscore/underscore.js',
//'underscore.string.js': 'underscore.string/underscore.string.js'
}
}
}
});
grunt.loadNpmTasks('grunt-bowercopy');
grunt.loadNpmTasks('grunt-contrib-jshint');
};
Run bower init to give yourself a bower.json file for the bowercopy task to read. Also if you already have installed everything via bower, set runBower to false in your options hash.
If you're ever having Grunt failures, it's worth running with the --v (verbose) flag to see exactly what it's failing on. Running this myself I saw it looking for a bower.json, and once I supplied one the task succeeded.
You're missing task registration, You need to register a task that you want to explicity run in grunt, so you need this
grunt.registerTask('bowercopy', ['bowercopy']);
Then you can run
grunt bowercopy
Since I can't comment on #dcodesmith's answer due to points, I have to leave an answer. I ran into the problem in that actually adding grunt.registerTask('bowercopy', ['bowercopy']);
called bowercopy's task, but it doesn't actually work. Removing it actually allowed bowercopy to copy files.

Grunt warning: No source files found

I am trying to use Grunt for the first time. I think that I'm properly following the directions to install and use Grunt with a plugin (grunt-text-replace). (See, for instance, Grunt's page and the plugin's.) But I can't successfully run anything -- instead, I keep getting the same error. I've been checking my code against the instructions from both Grunt and the plugin, but I can't see anything I did wrong.
Here is my package.json file:
{
"name": "brink-prototype",
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-text-replace": "~0.3.2"
}
}
And here is my Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
src: ['components/bootstrap/less/navbar.less'],
dest: 'build/',
replacements: [{
from: /\.box-shadow.*$/g,
to: ''
}]
}
});
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('default', ['replace']);
};
When I run "grunt" in the command line, I get the following error:
Running "replace:src" (replace) task
Warning: No source files found Use --force to continue.
Aborted due to warnings.
I also tried this process with another plugin (grunt-regex-replace) and had exactly the same error message.
Where have I gone wrong?
UPDATE:
Here are the relevant parts of the file structure:
project/
Gruntfile.js
package.json
components/
bootstrap/
less/
navbar.less
node_modules/
grunt/
grunt-text-replace/
I have been trying to run the command from the project/ directory, where the Gruntfile.js is.
Maybe the path in my src should be relative to something else? I don't know.
The grunt-text-replace plugin requires you to specify a subtask.
replace: {
aSubtaskName: {
src: ['components/bootstrap/less/navbar.less'],
dest: 'build/',
replacements: [{
from: /\.box-shadow.*$/g,
to: ''
}]
}
}

Resources