0

I wanted to use JQuery within Webstorm, but as soon as I use something like $("*") I get an error(when working in a JS-file):

console.log($("*"));

ReferenceError: $ is not defined
at ...\app.js:41:21
at FSReqWrap.oncomplete (fs.js:95:15)
Process finished with exit code 1

What I did so far is I included the jquery file in my layout-page(master page) in the head section and it works.

Under Settings and Libraries I checked JQuery.

But I still got that error, I think I have to change some settings in Webstorm...?!

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
user254197
  • 883
  • 2
  • 9
  • 31

2 Answers2

0

If you takl about checking at WebStrom - add at the begining of file

/* global $ */

Read more at http://usejsdoc.org/tags-global.html

And if you talk about running program - you should include file where $ defined

Vasiliy vvscode Vanchuk
  • 7,007
  • 2
  • 21
  • 44
  • I get the same error...when I use /* global $ */ or /** @global */ – user254197 May 26 '15 at 03:51
  • As I see - you run your script and got an error. That is mean that $ is undefined at your script. Did you include jquery file like "var $ = require('jquery')" or something else? – Vasiliy vvscode Vanchuk May 26 '15 at 06:27
  • now I get this: "module.js:338 throw err; ^ Error: Cannot find module 'jquery' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (..e.js:6:9) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) Process finished with exit code 1" – user254197 May 26 '15 at 06:58
  • Of course. It was just example. What do you what to do with jquery at server side? – Vasiliy vvscode Vanchuk May 26 '15 at 08:58
  • Please read http://stackoverflow.com/questions/1801160/can-i-use-jquery-with-node-js – Vasiliy vvscode Vanchuk May 26 '15 at 08:59
  • I want to list all files in a folder and then use the result in a template(handlebars) https://sankartypo3.wordpress.com/2013/02/12/how-to-list-files-and-folders-using-nodejs/ – user254197 May 26 '15 at 10:41
  • I'm not sure than $ is jQuery in that case – Vasiliy vvscode Vanchuk May 26 '15 at 12:42
0

I'd suggest looking at jsdom module if you like to do smth like this using Node.js. See usage examples in readme

lena
  • 90,154
  • 11
  • 145
  • 150