{"action":"created","issue":{"url":"https://api.github.com/repos/grncdr/npm-watch/issues/15","repository_url":"https://api.github.com/repos/grncdr/npm-watch","labels_url":"https://api.github.com/repos/grncdr/npm-watch/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/grncdr/npm-watch/issues/15/comments","events_url":"https://api.github.com/repos/grncdr/npm-watch/issues/15/events","html_url":"https://github.com/grncdr/npm-watch/issues/15","id":144988491,"number":15,"title":"Line endings break cli.js on Unix Machines","user":{"login":"jcpst","id":4027669,"avatar_url":"https://avatars.githubusercontent.com/u/4027669?v=3","gravatar_id":"","url":"https://api.github.com/users/jcpst","html_url":"https://github.com/jcpst","followers_url":"https://api.github.com/users/jcpst/followers","following_url":"https://api.github.com/users/jcpst/following{/other_user}","gists_url":"https://api.github.com/users/jcpst/gists{/gist_id}","starred_url":"https://api.github.com/users/jcpst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcpst/subscriptions","organizations_url":"https://api.github.com/users/jcpst/orgs","repos_url":"https://api.github.com/users/jcpst/repos","events_url":"https://api.github.com/users/jcpst/events{/privacy}","received_events_url":"https://api.github.com/users/jcpst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-31T19:00:18Z","updated_at":"2016-03-31T21:42:06Z","closed_at":null,"body":"After I upgraded a project to npm-watch@0.1.2, it was blowing up on me with the following error:\r\n\r\n```\r\n> npm-watch\r\n\r\n/usr/bin/env: ‘node\\r’: No such file or directory\r\n\r\nnpm ERR! Linux 4.4.5-1-ARCH\r\nnpm ERR! argv \"/home/joe/.nvm/versions/node/v4.4.1/bin/node\" \"/home/joe/.nvm/versions/node/v4.4.1/bin/npm\" \"run\" \"watch\"\r\nnpm ERR! node v4.4.1\r\nnpm ERR! npm  v3.8.3\r\nnpm ERR! file sh\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno ENOENT\r\nnpm ERR! syscall spawn\r\nnpm ERR! supwithnpm-watch@1.0.0 watch: `npm-watch`\r\nnpm ERR! spawn ENOENT\r\n```\r\n\r\nSo I cloned this repo, did a `npm link` and it worked fine, giving me the suspicion that this was a line ending issue. \r\n\r\nI then installed `npm-watch` in a local project, it failed with the same issue. After running the following one-liner to clobber the Windows line-endings:\r\n\r\n```shell\r\nsed 's/\\r$//' -i node_modules/npm-watch/cli.js\r\n```\r\n\r\nIt worked fine again. This puzzled me because all I saw in the git history was the removal of that `console.log()`.\r\n\r\nI did a little research, and this is an open issue with npm and cross-platform compatibility: https://github.com/npm/npm/issues/2097\r\n\r\nSo if you published from a Windows machine, `npm publish` sends the `\\r\\n`, but then `git commit` is converting the line endings and commiting `\\n`, so you never see it in the repo."},"comment":{"url":"https://api.github.com/repos/grncdr/npm-watch/issues/comments/204142320","html_url":"https://github.com/grncdr/npm-watch/issues/15#issuecomment-204142320","issue_url":"https://api.github.com/repos/grncdr/npm-watch/issues/15","id":204142320,"user":{"login":"jcpst","id":4027669,"avatar_url":"https://avatars.githubusercontent.com/u/4027669?v=3","gravatar_id":"","url":"https://api.github.com/users/jcpst","html_url":"https://github.com/jcpst","followers_url":"https://api.github.com/users/jcpst/followers","following_url":"https://api.github.com/users/jcpst/following{/other_user}","gists_url":"https://api.github.com/users/jcpst/gists{/gist_id}","starred_url":"https://api.github.com/users/jcpst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcpst/subscriptions","organizations_url":"https://api.github.com/users/jcpst/orgs","repos_url":"https://api.github.com/users/jcpst/repos","events_url":"https://api.github.com/users/jcpst/events{/privacy}","received_events_url":"https://api.github.com/users/jcpst/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T21:42:06Z","updated_at":"2016-03-31T21:42:06Z","body":"I agree, it would be nice if npm's 'publish' command. But! I have an idea.\r\n\r\nThere is a module called [crlf](https://www.npmjs.com/package/crlf) that will convert `\\r\\n` to `\\n`\r\n\r\nI just smoke-tested it and it appears to work fine.\r\n\r\nIf you create a `prepublish` lifecycle script and use it in there, that _should_ take care of it before every time you publish.\r\n\r\n```javascript\r\n{\r\n  \"scripts\": {\r\n    \"prepublish\": \"crlf --set=LF cli.js\"\r\n  }\r\n}\r\n```\r\n\r\nOr something else similar that uses that `prepublish` hook."}}