Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"npm run lint" fails on Windows #8021

Closed
andrerpena opened this issue Oct 19, 2016 · 4 comments
Closed

"npm run lint" fails on Windows #8021

andrerpena opened this issue Oct 19, 2016 · 4 comments

Comments

@andrerpena
Copy link

"npm run lint" fails on Windows, at least Windows 7.

Error:

Running "eslint" task
[17:46:07] Using gulpfile C:\Projetos\Git\react\gulpfile.js
[17:46:07] Starting 'eslint'...
C:\Projetos\Git\react\node_modules.bin\eslint.cmd:1
(function (exports, require, module, __filename, __dirname) { @if EXIST "%~dp0\node.exe" (
^
SyntaxError: Unexpected token ILLEGAL
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (node.js:348:7)
at startup (node.js:140:9)
at node.js:463:3
[17:46:08] Lint failed
Fatal error: Something went wrong running gulp:

Screenshot:

image

I found this "related" error in mocha but I couldn't fix it anyway.

What might it be?

@jddxf
Copy link
Contributor

jddxf commented Nov 7, 2016

I encountered the same problem. If you look into the code in gulp/tasks/eslint.js, you'll find the following code:

spawn(
      process.execPath,
      [
        path.join('node_modules', '.bin', 'eslint' + extension),
        '.',
      ],
      {
        // Allow colors to pass through
        stdio: 'inherit',
      }
    )

which spawns a new process using the command "node node_modules.bin\eslint.cmd .". The command tries to interpret a batch file using node. However node can interpret js files only. That's why there's a SyntaxError.
A change like this should work as expected:

spawn(
      path.join('node_modules', '.bin', 'eslint' + extension),
      ['.'],
      {
        // Allow colors to pass through
        stdio: 'inherit',
      }
    )

@gaearon
Copy link
Collaborator

gaearon commented Nov 8, 2016

@jddxf Would you like to send a PR if you have a working fix?

@jddxf
Copy link
Contributor

jddxf commented Nov 9, 2016

@gaearon Sure. I'll fix the same problem in gulp flow task too.

gaearon pushed a commit that referenced this issue Nov 9, 2016
Fix gulp tasks: eslint and flow error on Windows
acusti pushed a commit to brandcast/react that referenced this issue Mar 15, 2017
Fix gulp tasks: eslint and flow error on Windows
@gaearon
Copy link
Collaborator

gaearon commented Oct 4, 2017

I rolled this into #9540.

@gaearon gaearon closed this as completed Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants