Yarn: npm run script broken on Windows

Created on 29 Dec 2016  Â·  9Comments  Â·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

bug

What is the current behavior?

C:\Code\UniversitySite [code-quality ≡ +0 ~1 -0 !]> npm run lint

> [email protected] lint C:\Code\UniversitySite
> gulp lint

s" lint was unexpected at this time.
C:\Code\UniversitySite [code-quality ≡ +0 ~1 -0 !]> yarn run lint
yarn run v0.18.1
$ gulp lint
s" lint was unexpected at this time.

__note:__ it doesn't matter what the gulp task is.

Please mention your node.js, yarn and operating system version.

node v6.6.0
yarn v0.18.1
Windows 10

Everything works as expected on macOS and linux, Windows just doesn't want to behave (what's new...)

This may be a dupe, but I couldn't find anything OS specific in the issue tracker. If so, my apologies.

cat-bug

Most helpful comment

We are experiencing this issue also, on Windows 7 desktops as well as our Server 2012R2 build servers.

The package we are experiencing this issue with is Jest.

Bad node_modules/bin/jest.cmd

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\jest\bin\jest.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\jest\bin\jest.js" %*
)s" %*
)

All 9 comments

Try dropping the word run. Just type "yarn lint". It has been working for me on Window 10. Installing global packages and publish are still broken in 18.1 on Windows 10 though. At least for me.

I'm dealing with this issue as well, preventing use of yarn in production.

I have the same issue on Windows 10 :(

It looks like the generated node_modules/.bin/gulp.cmd contains an invalid part.

This is how its generated:

@IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" "%~dp0\..\gulp\bin\gulp.js" %* ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node "%~dp0\..\gulp\bin\gulp.js" %* )s" %* )

and it should look like this (notice the missing s" %*))

@IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" "%~dp0\..\gulp\bin\gulp.js" %* ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node "%~dp0\..\gulp\bin\gulp.js" %* )

@OhBizzle, @caseyWebb: changing this by hand fixed the issue for me!

We are experiencing this issue also, on Windows 7 desktops as well as our Server 2012R2 build servers.

The package we are experiencing this issue with is Jest.

Bad node_modules/bin/jest.cmd

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\jest\bin\jest.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\jest\bin\jest.js" %*
)s" %*
)

@narthollis We just got the same error on my colleague's Windows machine also with the jest package.

I don't have the time to debug this at the moment but if you or anyone else is interested, here's some info which I managed to gather:

  1. The error appeared in 2 out of 3 attempts so there might be a race condition involved. Each time we would remove the node_modules directory and run yarn install from scratch.
  2. The error appeared with the following yarn versions: 0.18.1 and 0.19.1.
  3. I would start looking within https://github.com/yarnpkg/yarn/blob/master/src/package-linker.js which uses the cmd-shim package to generate this erroneous jest.cmd file. I am guessing yarn is passing incorrect arguments to cmd-shim in certain circumstances.

Hope that helps!

Omitting "run" appeared to be working, but no more.

We can work around currently by invoking node and the module. It's messy, but it works.

{
  "scripts": {
    "install": "node node_modules/napa/bin/napa",
    "build": "node node_modules/gulp/bin/gulp.js build"
  }
}

This issue should be closed via #2795

@BYK @kaylieEB @bestander Closeable

Was this page helpful?
0 / 5 - 0 ratings