gruntjs / grunt-cli

Grunt's command line interface.
http://gruntjs.com/
MIT License
706 stars 248 forks source link

node_modules\.bin\grunt in CMD and PowerShell Errors With a Syntax Error When it Shouldn't #113

Closed epicstar closed 7 years ago

epicstar commented 7 years ago

Description

When I try to run grunt via node_modules\.bin\grunt in cmd or powershell, I get the following error:

$ node_modules\.bin\grunt
t"  was unexpected at this time.
username@pc <CURRENT_FOLDER>
)t"

However, running grunt directly using node node_modules\grunt\bin\grunt runs fine.

The cause of the issue is that line 7 of grunt.cmd has the following (at least on my computer):

)t" %*

Removing t" solves the problem. I will be able to create a simple pull request that fixes this issue on the weekend.

Environment

Node was installed through Chocolatey.

shama commented 7 years ago

node_modules\.bin\grunt.cmd is automatically generated by npm when grunt is installed. I'm guessing it's likely an issue with your environment or an issue with the specific version of npm you have installed.

kneumei commented 7 years ago

@epicstar did you figure this out? I'm seeing same problem

epicstar commented 7 years ago

I have not figured it out, but I'm just calling grunt in node_modules/grunt instead of node_modules/.bin/grunt.cmd in Windows.

It's not worth my time since I only incidentally found this issue in another project we are using that is primarily built on Unix but sometimes (optionally) built in Windows.

I don't exactly understand why this was closed.... I think it's worth investigating to find out the culprit, which I suspect is a bad mix between OS and NPM version.

shama commented 7 years ago

It was closed because it is not an issue with grunt-cli. grunt-cli doesn't generate those files, npm does.

Even if somebody wanted to help investigate (although you've indicated it's not worth your time, so I'm not sure if anyone else will think it's worth their time), it would be very difficult for them as they don't have the same environment and steps that causes the issue.

scottnonnenberg commented 6 years ago

This has been an intermittent issue for the Signal Desktop project on Windows for quite some time now, but today it happened four times in a row on AppVeyor:

  1. https://ci.appveyor.com/project/Signal-Desktop/signal-desktop/build/335
  2. https://ci.appveyor.com/project/Signal-Desktop/signal-desktop/build/334
  3. https://ci.appveyor.com/project/Signal-Desktop/signal-desktop/build/333
  4. https://ci.appveyor.com/project/Signal-Desktop/signal-desktop/build/332

I even updated the build to print out the current value of grunt.cmd before it starts, and sure enough, the last six characters of the script are repeated:

$ type node_modules\.bin\grunt.cmd
@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\grunt\bin\grunt" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\grunt\bin\grunt" %*
)t" %*
)

Usually when this happens and I do a rebuild the issue goes away. This time it hasn't, three times in a row. I'm gonna hit rebuild, see what happens this time...