yarn icon indicating copy to clipboard operation
yarn copied to clipboard

yarn run + npm scripts

Open steveklabnik opened this issue 10 years ago • 21 comments

This might be a duplicate of https://github.com/yarnpkg/yarn/issues/733 but I'm not sure.

In https://github.com/rust-lang/crates.io/pull/457, we're trying to move to yarn. It's an ember app, and so relies on things like ember test to run tests.

The important part of the diff is here: https://github.com/rust-lang/crates.io/pull/457/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R10

That is, we have several npm scripts that, in my understanding, should be prefixed with yarn run. But on Travis, and possibly in other configurations, this seems to fail.

Am I Doing it Wrong, or is this a bug?

steveklabnik avatar Oct 12 '16 01:10 steveklabnik

Are you seeing an error message?

Daniel15 avatar Oct 12 '16 01:10 Daniel15

Also reported in https://github.com/yarnpkg/yarn/issues/782

nodesocket avatar Oct 12 '16 02:10 nodesocket

@Daniel15

error Command failed with exit code 127

is what I get when I try yarn start.

shri3k avatar Oct 12 '16 02:10 shri3k

Ah sorry, the rebase made Travis go away. If you look at the comments, @carols10cents shows an error.

On Oct 11, 2016, 22:36 -0400, Yojan Shrestha [email protected], wrote:

@Daniel15 (https://github.com/Daniel15)

error Command failed with exit code 127

is what I get when I try yarn start.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub (https://github.com/yarnpkg/yarn/issues/780#issuecomment-253103014), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABsiqa0NJCciwUDKNGTnHNmmzx-kibJks5qzEeSgaJpZM4KUQ7o).

steveklabnik avatar Oct 12 '16 02:10 steveklabnik

Taking a look at https://yarnpkg.com/en/docs/cli/run , the usage should be yarn run blah where blah is a key in the scripts object in package.json. I don't think you want your yarn runs in the script blocks unless they need to reference other script items.

Try changing yarn run ember test in .travis.yml to yarn run test and change "test": "yarn run ember test" in package.json to "test": "ember test" and see if that gets you closer.

FLGMwt avatar Oct 12 '16 05:10 FLGMwt

@FLGMwt that would make sense, thanks. I've pushed a commit, we'll see what travis says.

steveklabnik avatar Oct 12 '16 13:10 steveklabnik

FWIW, I'm experiencing the same issue as @steveklabnik in the same context (i.e. ember commands).

For example, I have scripts in my package.json like this:

  "scripts": {
    "build": "ember build",
    "start": "ember server",
    "test": "ember try:each",
    "test:dev": "ember test --filter ESLint -i",
    "tdd": "npm run test:dev -- -s",
    "lint": "ember test --filter ESLint"
  },

npm run test will run the script located at the test key in the scripts object (i.e. ember try:each).

yarn run test does the following:

screen shot 2016-10-12 at 11 03 35 am

So it seems that there's a disconnect where yarn run might not be correctly accessing the .bin folder in node_modules?

FWIW, yarn run ember try:each DOES work, so it seems the issue is scoped to actually calling .bin commands from the scripts hash.

cafreeman avatar Oct 12 '16 16:10 cafreeman

Seeing an similar issue. If the script in package.json is a single command it will run. If the command has arguments or is a compound command (or contains a space), the script fails with exit code 127.

scothis avatar Oct 12 '16 16:10 scothis

This should be fixed in #809

randycoulman avatar Oct 12 '16 16:10 randycoulman

@randycoulman looks like it.

What's yarn's release schedule gonna look like? Any idea when that'll hit a release?

steveklabnik avatar Oct 12 '16 17:10 steveklabnik

Any eta on releasing this?

nodesocket avatar Oct 13 '16 08:10 nodesocket

@scothis same problem here:

  "scripts": {
    "start": "node server.js",
    "test": "mocha"
  },

yarn

$ yarn start
yarn start v0.15.1
$ "node server.js" 
sh: node server.js: command not found
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/start for documentation about this command.

npm

$ npm start

> [email protected] start /path/to/project
> node server.js

npm runs fine, but yarn errors out. I tried yarn run start as well and got the same results. If I remove server.js from the start script, the node repl starts up just fine.

dougludlow avatar Oct 13 '16 19:10 dougludlow

As stated #809 will resolve this.

Thanks everyone!

samccone avatar Oct 13 '16 20:10 samccone

Gracias @dougludlow

alhexanderad avatar Nov 08 '16 22:11 alhexanderad

I am experiencing similar issue in Yarn version 0.17.8.

Basically, I cannot reference yarn run inside of one of my scripts, I have to use npm run...

This works! Referencing npm run inside of the build script

package.json
--------------

"scripts": {
    "gulp": "gulp",
    "bower": "gulp bower",
    "build": "npm run bower && npm run gulp"
}

CLI
--------------

$ yarn build

But this does not work, referencing yarn run inside of build script...

package.json
--------------

"scripts": {
    "gulp": "gulp",
    "bower": "gulp bower",
    "build": "yarn run bower && yarn run gulp"
}

CLI
--------------

$ yarn build

Output...

 ➥  yarn run build
yarn run v0.17.8
$ yarn run bower && yarn run gulp
/www/node_modules/yarn/bin/yarn.js:62
      throw err;
      ^

Error: ENOENT: no such file or directory, open '/www/node_modules/proper-lockfile/node_modules/extend/index.js'
    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at Object.Module._extensions..js (module.js:421:20)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/www/node_modules/proper-lockfile/index.js:5:14)
    at Module._compile (module.js:413:34)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I am not sure if this issue was re-introduced at some point after #809 or if this is an entirely different issue.

  • I am running macOS Sierra 10.12.1
  • All dependencies are installed locally minus Yarn (so, either npm run gulp or yarn run gulp is necessary to execute)

If you are aware of an existing issue already addressing this please point me in that direction. I have found several very similar issues but they don't quite address the same problem.

kstoddard avatar Nov 22 '16 16:11 kstoddard

Has this been resolved? Im using buble (https://buble.surge.sh) trying to output code into a .js file like so;

yarn buble input.js > output.js

I get the annoying (unnecessary) gibberish in my file.

yarn buble v0.17.8
$ node ./node_modules/.bin/buble demo.js
var name = function () { return 'Sabelo'; };

Done in 0.63s.

ghost avatar Nov 30 '16 16:11 ghost

@ElvisMagagula - That looks like a separate issue, could you please file a separate GitHub issue for it?

Daniel15 avatar Nov 30 '16 18:11 Daniel15

@kstoddar currently in the same position

mamartins avatar Jan 09 '17 16:01 mamartins

Can anyone please help me with some information related to following.

events.js:182 throw er; // Unhandled 'error' event ^

Error: watch /home/pavan/ALPS/web-alps/public ENOSPC at exports._errnoException (util.js:1022:11) at FSWatcher.start (fs.js:1384:19) at Object.fs.watch (fs.js:1410:11) at createFsWatchInstance (/home/pavan/ALPS/web-alps/node_modules/chokidar/lib/nodefs-handler.js:37:15) at setFsWatchListener (/home/pavan/ALPS/web-alps/node_modules/chokidar/lib/nodefs-handler.js:80:15) at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/pavan/ALPS/web-alps/node_modules/chokidar/lib/nodefs-handler.js:228:14) at FSWatcher.NodeFsHandler._handleDir (/home/pavan/ALPS/web-alps/node_modules/chokidar/lib/nodefs-handler.js:407:19) at FSWatcher. (/home/pavan/ALPS/web-alps/node_modules/chokidar/lib/nodefs-handler.js:455:19) at FSWatcher. (/home/pavan/ALPS/web-alps/node_modules/chokidar/lib/nodefs-handler.js:460:16) at FSReqWrap.oncomplete (fs.js:153:5) error Command failed with exit code 1.

This error sometimes it appear and sometimes it doesn`t.

Thanks, Pavan.

pavankumarbijja avatar Aug 07 '17 22:08 pavankumarbijja

@pavankumarbijja this is a question for StackOverflow or Google. Google ENOSPC and you'll get your answer ;)

BYK avatar Aug 08 '17 08:08 BYK