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

yarn run + npm scripts #780

Closed
steveklabnik opened this issue Oct 12, 2016 · 21 comments
Closed

yarn run + npm scripts #780

steveklabnik opened this issue Oct 12, 2016 · 21 comments

Comments

@steveklabnik
Copy link

This might be a duplicate of #733 but I'm not sure.

In rust-lang/crates.io#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?

@Daniel15
Copy link
Member

Are you seeing an error message?

@nodesocket
Copy link

Also reported in #782

@shri3k
Copy link

shri3k commented Oct 12, 2016

@Daniel15

error Command failed with exit code 127

is what I get when I try yarn start.

@steveklabnik
Copy link
Author

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 (#780 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABsiqa0NJCciwUDKNGTnHNmmzx-kibJks5qzEeSgaJpZM4KUQ7o).

@FLGMwt
Copy link
Contributor

FLGMwt commented Oct 12, 2016

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.

@steveklabnik
Copy link
Author

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

@cafreeman
Copy link

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.

@scothis
Copy link

scothis commented Oct 12, 2016

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.

@randycoulman
Copy link
Contributor

This should be fixed in #809

@steveklabnik
Copy link
Author

@randycoulman looks like it.

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

@nodesocket
Copy link

Any eta on releasing this?

@dougludlow
Copy link

@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.

@samccone
Copy link
Member

As stated #809 will resolve this.

Thanks everyone!

@alhexanderad
Copy link

Gracias @dougludlow

@kstoddard
Copy link

kstoddard commented Nov 22, 2016

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.

@ghost
Copy link

ghost commented Nov 30, 2016

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.

@Daniel15
Copy link
Member

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

@mamartins
Copy link

@kstoddar currently in the same position

@pavankumarbijja
Copy link

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.

@BYK
Copy link
Member

BYK commented Aug 8, 2017

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

@bilalmajeed64
Copy link

yarn run v1.12.3
node v10.14.2
npm 6.4.1

What is happening?
yarn didn't run any command and show this error

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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