pluma / dirwatch

DEPRECATED. Use the watch package instead.
MIT License
3 stars 0 forks source link

Can't use npm #1

Open togakangaroo opened 9 years ago

togakangaroo commented 9 years ago

Windows 8.1 node v0.10.32

I'm trying to play around with using npm as a build tool as hypothesized in this article.and am running into a problem when using dirwatch to launch npm.

I have the following scripts in my package.json

"scripts": {
  "npmversion": "npm -v",
  "watch:npmversion": "dirwatch -v -c 'npm run npmversion' .",
  "watch:path": "dirwatch -v -c 'echo %PATH%' ."
},

Running this I get

W:\noframeworks> npm run npmversion

> noframeworks@0.0.0 npmversion W:\noframeworks
> npm -v

1.4.28

Ok, that works great

W:\noframeworks> npm run watch:npmversion

> noframeworks@0.0.0 watch:npmversion W:\noframeworks
> dirwatch -v -c 'npm run npmversion' .

[23:37:50.192] Watching run ...
[23:37:50.192] Watching npmversion' ...
[23:37:50.207] Watching . ...
[23:38:02.707] Change detected in index.js
[23:38:02.707] Executing command ...
[23:38:02.707] Change detected in .subl366.tmp
[23:38:02.707] Executing command ...
{ [Error: Command failed: ''npm' is not recognized as an internal or external command,
operable program or batch file.
] killed: false, code: 1, signal: null }
''npm' is not recognized as an internal or external command,
operable program or batch file.
{ [Error: Command failed: ''npm' is not recognized as an internal or external command,
operable program or batch file.
] killed: false, code: 1, signal: null }
''npm' is not recognized as an internal or external command,
operable program or batch file.
[23:38:02.848] Change detected in .sublcd0.tmp
[23:38:02.848] Executing command ...
[23:38:02.848] Change detected in index.js
[23:38:02.848] Executing command ...
{ [Error: Command failed: ''npm' is not recognized as an internal or external command,
operable program or batch file.
] killed: false, code: 1, signal: null }
''npm' is not recognized as an internal or external command,
operable program or batch file.
{ [Error: Command failed: ''npm' is not recognized as an internal or external command,
operable program or batch file.
] killed: false, code: 1, signal: null }
''npm' is not recognized as an internal or external command,
operable program or batch file.
^CTerminate batch job (Y/N)? y

Huh? npm not recognized? It should be on my PATH.

W:\noframeworks> npm run watch:path

> noframeworks@0.0.0 watch:path W:\noframeworks
> dirwatch -v -c 'echo %PATH%' .

\Microsoft was unexpected at this time.

W:\noframeworks>  "W:\noframeworks\node_modules\.bin\\node.exe"  "W:\noframeworks\node_modules\.bin\\..\dirwatch\bin\dirwatch" -v -c 'echo C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;W:\noframeworks\node_modules\.bin;C:\Program Files\nodejs\;C:\Program Files\ConEmu\ConEmu;C:\Program Files\ConEmu;C:\Program Files\ImageMagick-6.8.7-Q16;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;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:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Universal Extractor;C:\Program Files (x86)\Universal Extractor\bin;C:\Program Files\OpenVPN\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\nodejs\;C:\Program Files\TortoiseHg\;C:\Program Files\Mercurial\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\;C:\Program Files (x86)\vim\vim74;C:\ProgramData\chocolatey\bin;C:\Program Files\Gallio\bin;C:\Program Files (x86)\Git\cmd;C:\PhantomJS;C:\tools\mysql\current\bin;C:\Users\George\AppData\Roaming\npm;C:\Users\George\Documents\WindowsPowerShell\Modules\pscx\Apps' .

npm ERR! noframeworks@0.0.0 watch:path: `dirwatch -v -c 'echo %PATH%' .`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the noframeworks@0.0.0 watch:path script.
npm ERR! This is most likely a problem with the noframeworks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     dirwatch -v -c 'echo %PATH%' .
npm ERR! You can get their info via:
npm ERR!     npm owner ls noframeworks
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch:path"
npm ERR! cwd W:\noframeworks
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     W:\noframeworks\npm-debug.log

npm ERR! not ok code 0

hmm, that contains C:\Program Files\nodejs\ which is the location of npm.cmd. So what's going on? Why can't I use npm?

togakangaroo commented 9 years ago

By the way I've looked at the codebase and tried doing this and it works just fine so it seems like the issue would be somewhere inside dirwatch code or it's binary

var exec = require('child_process').exec;

exec('npm run npmversion', function (err, stdout, stderr) {
if (err) console.error(err);
if (stdout) console.log(stdout.replace(/\n$/, ''));
    if (stderr) console.warn(stderr.replace(/\n$/, ''));
});
pluma commented 9 years ago

I haven't tested this module on Windows at all, sadly. I'm fairly certain it's a Windows-specific issue as I've been using dirwatch with npm under Linux from the start.

The odd thing is that the last example you're giving is exactly what dirwatch is doing.

Could you try out something to help with debugging this problem? Open the node_modules/dirwatch/bin/dirwatch file (it's JavaScript) and add console.log(">> CMD:", argv.cmd); before line 31. Then try again and tell me what the output looks like.

I'm guessing something is going wrong while parsing the arguments.