grunt-contrib-jshint warning: path must be a string; - node.js

I've been trying to use the jshint grunt module to validate my code, but I always get the following error:
Running "jshint" task
[D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js
Running "jshint:all" (jshint) task
[D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js
Verifying property jshint.all exists in config...OK
Files: Gruntfile.js, app/scripts/app.js
Options: force=false, reporterOutput=null, jshintrc=".jshintrc", reporter={}
Warning: Path must be a string. Received { toString: [Function], reporter: [Function] } Use --force to continue.
the problem is that even using the --verbose and -debug, it doesnt show anything to work on the error, just "path must be a string", i validated the file with JSLint (using brackets) and it works quite well, website also works fine.
what i have done so far.
Unistalled node.js and node modules 3 times (trying something different everytime).
tried to limit my grunt task to simply validate a very simple js file, and also doesnt work, it means thats not related to the code or my gruntfile.js.

I fixed this issue by updating grunt-contrib-jshint from "0.10.0" to "0.12.0".

I was still getting the error after updating node to v6.4.0.
What helped me was this comment on github (by Jeff Peck):
I have found the issue to be when the reporterOutput option is set to
null. If you change that option to refer to an empty string, jshint
will work as expected:
options: {
jshintrc: '<%= baseDir %>/.jshintrc',
reporterOutput: "",
...
Doing that allowed grunt jshint to complete.
EDIT:
Well, I did have updated node, but not grunt-contrib-jshint, as per Zeid Selimovic's answer. That works and is better than previous workaround

I got the issue just after updation of node (v6.9.2). It got resolved after updating grunt-contrib-jshint to the latest version ("1.1.0") by following steps:
npm uninstall grunt-contrib-jshint --save-dev
npm install grunt-contrib-jshint --save-dev

Related

Parsing error: Unexpected token .. when using eslint

I'm fairly new to the linux webapp development scheme but there was a readme attached with the project that the previous team left me.
It said I have to call
sudo npm install
bower install
grunt build/grunt server.
firstly, my bower.json is empty with the exception of
{
"name": "webapp",
"dependencies": {
"roslib": "~0.15.0"
}
}
and secondly when I call grunt build I get the error
error Parsing error: Unexpected token let
I also get the same error with the tokens '<' and 'ILLEGAL'
Edit: I found that grunt build is defined as
grunt.registerTask('build', ['eslint', 'browserify', 'concat_css', copy']);
You should talk to the previous team and ask them about the project and get some rampup. You should probably also do at least a few tutorials on node/grunt/whatever else they're using.
As for your issues, firstly there's nothing wrong with the bower.json only having one dependency, that's not an issue. Bower seems to be declining though so you could also get roslib through npm, though you'd have to understand enough about the project to replace where it's being used to be from node_modules.
You're probably getting the error on grunt because they've used let in their Gruntfile.js and you're on an old version of node that doesn't support let yet. The latest long term support of node.js is 6.10.3. I would update if you can.

Noflo example : Running inside browser

We are trying to get a simple noflo example running inside a browser as described the noflojs.org/documentation/fbp/ [Language for Flow-Based Programming]
We tried to refer to some examples available on GitHub
github.com/noflo/noflo-browser-app
github.com/noflo/noflo-websocket
github.com/bergie/flowcopter
We tried npm install; grunt build. We get the below error and are not able to proceed beyond this:
Running "noflo_browser:build" (noflo_browser) task install
noflo/noflo#master Warning: dns lookup failed Use --force to
continue.
Any idea what are we missing ?
At the time of the question the build setup for the projects mentioned was still based on Component.js which had become unmaintained.
Nowadays we're using NPM for installing dependencies and WebPack for browser builds.
Suggested fix would be to fetch the latest versions of these repos, do npm install and build again. This will bring the build up to spec.
If you're using the old build setup in your own projects, this PR is a handy example on what to change to go from Component.js to WebPack.

How can I get WebStorm to show me a list of bower packages?

Good morning.
My setup:
OSX El Capitan 10.11.2
JetBrains WebStorm 11.0.2
Node.js 4.2.3
NPM version 2.14.7
Bower 1.7.0
Npm's prefix to~/.npm-global
My executable path is set: $PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/mike/.npm-global/bin
Running bower search [package] --json from the command line does return results.
The relevant lines (when Webstorm runs the search) from my log look like:
2015-12-10 10:11:20,252 [1087432] INFO - ipt.bower.BowerCommandLineUtil - Running bower command: /usr/local/bin/node /Users/mike/.npm-global/bin/bower search --json
2015-12-10 10:11:20,739 [1087919] WARN - .BowerAvailablePackagesManager - [parse all bower packages] Top-level element should be object, but BEGIN_OBJECT found.
I did note that bower search --json (like Webstorm does, without specifying a package) returns bower usage information as a json object, which is funny, and I'm fairly confident this is the problem. There are no relevant issues on the Webstorm forums.
This is really taking the 'I' out of 'IDE'.
Can anybody offer a solution?
Here's what I'm seeing (or not seeing).
UPDATE: I was correct in my original assumption but I lack the expertise and time to solve it properly. My workaround is shown below. Bower's search command is supposed to run without arguments but, when Webstorm calls bower search --json, the command is interpreted as incorrect and returns the search usage as a json object. Silly stuff. Hope this helps somebody else.
problem is caused by recent changes in Bower (https://github.com/eppeters/bower/commit/5a1e5eb9c717b4210d6a4af77eca1951bdd9f288); it now requires a module name neing passed to search command (though documentation hasn't yet been updated accordingly).
Related JetBrains ticket: WEB-19389; fixed, fix will be available in next update
This is a gross fix and is unsuitable for use as long as there is any hair remaining on your head:
In [npm prefix]/bin/lib/node_modules/bower/lib/util/cli.js
I added the following to intercept the command line options and force an empty search pattern:
function readOptions() {
...
noptOptions = nopt(types, shorthands, argv);
...
// ADDED THE FOLLOWING
if (noptOptions.argv.original.length == 2 && noptOptions.argv.original[0] == 'search' && noptOptions.argv.original[1] == '--json') {
noptOptions.argv = {
remain: ['search', ''],
cooked: ['search', '', '--json'],
original: ['search', '', '--json']
};
//////////////////////
...
}

Issues installing swiper.js (node.js/grunt noob)

Having issues getting swiper.js to work. Requires grunt/bower. I'm completely new to js generators and am only able to get through about half the walkthrough before running into issues.
When I type $grunt dist into terminal, I get the following response: -bash: dist: command not found
What step am I missing?
Followed the idangerous steps to the letter: http://www.idangero.us/sliders/swiper/plugins/scrollbar.php
I have most often see "X command not found" for one of the following reasons:
The project's Grunt dependencies aren't installed or aren't installed properly
Your Gruntfile is mis-configured or missing
To fix this, first make sure there is a package.json file in your project. This will tell the npm what dependencies the project has and install them accordingly (assuming the package.json file is also configured correctly).
Next, make sure you have installed grunt correctly.
If you're still having issues, open your Gruntfile and search for:
grunt.registerTask('dist
This will show where the "dist" task is being defined. If you for some reason don't find it, then there's your problem. If you do find it, then check the proceeding commands inside square brackets that look like this:
grunt.registerTask('dist', ['clean', 'dist-css', 'copy:fonts', 'dist-js', 'dist-docs']);
'clean', 'dist-css', etc. are all other tasks defined in the Gruntfile, and there could be an issue with those as well.
If there's an issue with your package.json or Gruntfile, then trying re-installing the project with bower and repeat the above steps to ensure that it's not an issue on your end.
If it's not, then something is probably wrong with the author's source code.

Using localForage and angular-localForage with Browserify causing errors with require statements

I am attempting to install localForage into a node.js application (with Angular) and Browserify.
Here is a link to the localForage documentation
It appears that using localForage and angular-localForage causes a problem with browserify based around the use of 'require'
If I require the localforage.js file in the src file I get the following error:
Warning: module "promise" not found from "/Users/mgayhart/Sites/epson- receipts/bower_components/localforage/src/localforage.js" Use --force to continue.
If I require the localforage.js file in the dist file, I get the following error:
Warning: module "./drivers/indexeddb" not found from "/Users/mgayhart/Sites/epson- receipts/bower_components/localforage/dist/localforage.js" Use --force to continue.
Anyone know of a workaround to be able to move forward with these libraries?
There is an issue on github with this problem: https://github.com/ocombe/angular-localForage/issues/26
I'll be working on it soon, you can subscribe to the github notifs on this issue to know when it's fixed !
For me installing it through bower and using it with browserify-shim worked. So in package.json:
"browser": {
"localforage":"./src/lib/vendor/localforage/dist/localforage.min.js"
},
"browserify-shim": {
"localforage":"localforage"
}
And to expose it as an angular-service (if you don't want to use angular-localforage):
app.factory "localforage",-> require 'localforage'
I've just been having this issue myself tonight, but I think I found a fix.
Instead of trying to get the bower modules to work with browserify, why not just use npm like its made for?
npm install localforage
and then when you use require you don't have to give it the path
but it still didn't work for me until I copied the folder:
localforage/src/drivers TO localforage/dist/drivers
Then it found all the dependencies and worked like a champ!
Alternatively if you must use bower you could try to use the debowerify tranform w/ gulp:
https://github.com/eugeneware/debowerify

Resources