Why does gulp.watch or fs.watch not work on Bash on Ubuntu on Windows? - windows

On Bash on Ubuntu on Windows, a gulp task like this;
gulp.task('default', function() {
gulp.watch('./', function() {console.log('change!')});
});
or just calling fs.watch directly from node;
node -e "require('fs').watch('./')"
both fail with the following;
Error: watch ./ EPERM
at exports._errnoException (util.js:1012:11)
at FSWatcher.start (fs.js:1429:19)
at Object.fs.watch (fs.js:1456:11)
at [eval]:1:15
at ContextifyScript.Script.runInThisContext (vm.js:25:33)
at Object.exports.runInThisContext (vm.js:77:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:541:32)
at bootstrap_node.js:315:29
at _combinedTickCallback (internal/process/next_tick.js:67:7)
How can I use gulp.watch under Bash on Ubuntu on Windows?

Currently Bash on Ubuntu on Windows has no support for filesystem watchers like inotify. You can vote for such a feature on the project's uservoice.
Further discussion in this github issue
EDIT: Looks like this has now been fixed in development and is set to be released to the general public sometime early 2017.

Related

gulp-ruby-sass not a recognized command in Windows

I'm trying out gulp for the first time on a Windows Server 2012 VM. I'm normally a Mac user, so I'm a bit new to Windows & Powershell for dev tools like this. I installed Node.js & npm (and nothing else). I created the following basic Gulpfile to compile my Sass:
Gulpfile.js
var gulp = require('gulp'),
sass = require('gulp-ruby-sass');
gulp.task('styles', function() {
return gulp.src('Content/sass_new/application.scss')
.pipe(sass({ style: 'expanded', }))
.pipe(gulp.dest('Content/css'))
});
gulp.task('watch', function() {
gulp.watch('Content/sass_new/*', ['styles']);
})
gulp.task('default', ['styles']);
In Windows Powershell, I run the gulp command, and it outputs the following:
[10:02:57] Using gulpfile C:\[path to]\gulpfile.js
[10:02:57] Starting 'styles'...
[10:02:57] gulp-ruby-sass: 'sass' is not recognized as an internal or external command,
operable program or batch file.
[10:02:57] Finished 'styles' after 316 ms
[10:02:57] Starting 'default'...
[10:02:57] Finished 'default' after 15 μs
Am I missing something here? Do I need to install Ruby or Sass? I thought to do that, I'd need a Ruby command prompt and PowerShell wouldn't have access to it. Any guidance is appreciated!
Yes that's right, you need to install Ruby and Sass to get gulp-ruby-sass working.
Begin by download the Ruby installer depending on your specs at this address. Once installed you supposed to have it on your system and accessible by PowerShell or the simple command line.
After, just run the command
gem install sass
And you're done.
Download and Install Ruby : http://rubyinstaller.org/
set ruby location to Path Environment Variable
restart the command prompt
and run gem install sass
That's it.

"cannot find module" when installing npm modules on windows

I am new to NodeJS. I am trying to use npm on Windows 8.
I have installed using chocolatey, cinst nodejs.install (version 0.10.17). I installed as administrator (and would prefer to run npm as a normal user).
Node itself seems to be working, I can use the REPL to run simple programs.
If I try to install something using npm, I get cannot find module:
> node npm install express
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\Klas\Documents\My Dropbox\mina egna\tech\node\webserver\npm'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
I have read the answers on Nodejs cannot find installed module on Windows? but unfortunately it is still unclear to me what I have to do.
I have tried setting NODE_PATH:
In trying to follow this answer, I have tried setting it to C:\Users\Klas\AppData\Roaming\npm\node_modules (but I had to create both the npm and the subfolder node_modules myself)
I have tried creating a folder c:\node\node_module (according to this advice, even though the installation did not even create a c:\node folder) and setting it to that.
I have tried setting it to C:\Program Files\nodejs\node_modules\npm\node_modules (which did exist after installation)
I have also tried to create a node_modules folder below the current working directory. As I understand it that is where local npm will be installed?
None of these helped. So it seems to me that setting NODE_PATH is not the solution?
Using the -g flag makes no difference (I would prefer not to use it).
I get the same error both as normal user and as administrator (I would prefer to be a normal user).
I get the same error no matter where I execute the command, except when I do it in C:\Program Files\nodejs, where I get
basedir=`dirname "$0"`
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
Not using windows, but I'm pretty sure it's just npm install express on windows too.

Setting up a LESS file watcher in PHPStorm 6 using node.js on Windows?

I'm a recent convert to PHPStorm and absolutely loving it. I'm trying to get the 'File Watcher' to work with my LESS code, and I want it to use the lessc command. I have node.js installed and the command 'lessc' works from the windows command prompt, but it doesn't want to work within PHPStorm.
Here is my configuration for the file watcher:
When the file watcher runs, I get this error appear continuously:
An exception occurred while executing watcher 'LESS'. Watcher is
disabled. Fix it.: Cannot run program
"C:\Users\Jason\AppData\Roaming\npm\lessc" (in directory
"F:\Plan2Share_v1\public\css"): CreateProcess error=193, %1 is not a
valid Win32 application
As soon as I enable the watcher again, it somehow disables and throws me the above error again. I'm very new to node.js and PHPStorm. Any direction on where I might be going wrong would be greatly appreciated.
EDIT: Following #josh3736 's direction. I now get his error in the Run console of PHPStorm.
"C:\Program Files\nodejs\node.exe" C:\Users\Jason\AppData\Roaming\npm\lessc F:\Plan2Share_v1\public\css\style.less
C:\Users\Jason\AppData\Roaming\npm\lessc:2 basedir=`dirname "$0"`
^ SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
That error tells us that PHPStorm is calling CreateProcess, which can only start executables. It cannot run scripts/batch files, which is what lessc is. (PHPStorm would have to use ShellExecute for that.)
To work around this limitation, you'll have to specify the Node installation (C:\Program Files\nodejs\node.exe most likely) as the executable, and the arguments should probably be something like C:\Users\Jason\AppData\Roaming\npm\node_modules\less\bin\lessc $FileName$
Change Program: C:\Users\Jason\AppData\Roaming\npm\lessc.cmd
Change Arguments: --no-color $FileName$
Apply
Image: https://dl.dropboxusercontent.com/u/4287697/2014-09-26_11h25_29.png

Working with compound js on windows. Cannot start anything

I wish to create a hello world application using compound.js.
So far, nothing works at all.
I've installed "npm install compound -g" to have compound be available globally.
Now I wish to run "compound init" and I get this:
(see first code block)
While googling, I found an example app on npm called mongoose-compound-example-app.
After npm installing that, I ran "node ." as suggested in the readme:
(see second code block)
I am using Windows 8 x64. Node itself works, and I've been able to run a "hello world" application using locomotive.js. I really want to get compound figured out and working, but I can't seem to get anywhere at all.
Thank you in advance!
EDIT:
I am using Node v0.10.0
C:\Users\Lev\test>compound init hello
path.js:204
throw new TypeError('Arguments to path.join must be strings');
^
TypeError: Arguments to path.join must be strings
at f (path.js:204:15)
at Object.filter (native)
at Object.exports.join (path.js:209:40)
at CompoundServer.module.exports [as extensions] (C:\Users\Lev\AppData\Roaming\npm\node_modules\compound\lib\server\extensions.js:13:25)
at CompoundServer.initCompound (C:\Users\Lev\AppData\Roaming\npm\node_modules\compound\lib\compound.js:100:14)
at CompoundServer.init (C:\Users\Lev\AppData\Roaming\npm\node_modules\compound\lib\server\compound.js:42:29)
at C:\Users\Lev\AppData\Roaming\npm\node_modules\compound\lib\compound.js:61:18
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:903:3
mongoose-compound-example-app error:
C:\Projects\mongoose-compound-example-app\config\environment.js:11
app.use(compound.assetsCompiler.init());
^
TypeError: Cannot call method 'init' of undefined
at Function.<anonymous> (C:\Projects\mongoose-compound-example-app\config\environment.js:11:41)
at Function.app.configure (C:\Projects\mongoose-compound-example-app\node_modules\express\lib\application.js:396:61)
at module.exports (C:\Projects\mongoose-compound-example-app\config\environment.js:10:9)
at evalInContextOf (C:\Projects\mongoose-compound-example-app\node_modules\compound\lib\compound.js:187:9)
at requireIfExists (C:\Projects\mongoose-compound-example-app\node_modules\compound\lib\compound.js:165:9)
at configureApp (C:\Projects\mongoose-compound-example-app\node_modules\compound\lib\compound.js:147:5)
at CompoundServer.initCompound (C:\Projects\mongoose-compound-example-app\node_modules\compound\lib\compound.js:91:9)
at CompoundServer.init (C:\Projects\mongoose-compound-example-app\node_modules\compound\lib\server\compound.js:42:29)
at C:\Projects\mongoose-compound-example-app\node_modules\compound\lib\compound.js:61:18
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:903:3
As discussed in the chat, there seems to be a problem or conflict with the version of Node.js you are using.
Compound's package.json says that it expects Node.js 0.8.0 or higher. You mentioned that it works in 0.9, but not in 0.10. This is likely a bug, as the odd-numbered versions of Node are typically the unstable versions before the later even number stable releases.
I recommend posting a reproducible example on the bug tracker for Compound, and possibly Node.js if you can narrow it down to a Node issue.

CoffeeScript and Cake

I installed CoffeeScript on my machine with npm install -g coffee-script I get the following message when I check cake version:
$ coffee -v
CoffeeScript version 1.3.3
[~]
$ cake -v
path.existsSync is now called `fs.existsSync`.
/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:108
throw new Error("Cakefile not found in " + (process.cwd()));
^
Error: Cakefile not found in /Users/Phil
at cakefileDirectory (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:108:11)
at cakefileDirectory (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:106:14)
at cakefileDirectory (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:106:14)
at Object.exports.run (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:49:19)
at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/coffee-script/bin/cake:7:38)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Does anyone know how can I fix this?
There are two issues here.
The first is a known issue which causes:
path.existsSync is now called `fs.existsSync`
You can find out more about the issue here:
https://github.com/jashkenas/coffee-script/pull/2411
As stated in the pull request, it should be fixed in the coffee-script master branch. So you can download the latest source from GitHub and it should resolve the issue for you.
Otherwise, try installing an older version of node:
http://nodejs.org/dist/v0.6.6/
The second issue which is addressed in other answers, is the need for a Cakefile in the directory that you are running the cake command in.
Cakefile should be exists in directory where you call cake
I had similar issue in cakephp3. Above solution didn't work. I was trying to bake plugin from the command line.
cake bake Plugin PageManager
After receiving above error, I changed my command to following and it worked like a charm .
./cake bake plugin PageManager
Hope it will help to someone who had similar issues as mine.

Resources