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

Stopped working with yarn #196

Open
nfantone opened this issue Jan 18, 2021 · 6 comments · Fixed by remix-run/remix#3595 · May be fixed by #260
Open

Stopped working with yarn #196

nfantone opened this issue Jan 18, 2021 · 6 comments · Fixed by remix-run/remix#3595 · May be fixed by #260

Comments

@nfantone
Copy link

nfantone commented Jan 18, 2021

While having the following scripts on package.json:

    "clean": "rimraf es lib dist",
    "build:es": "cross-env BABEL_ENV=es babel src/ --out-dir es",
    "build:cjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
    "build:umd": "rollup -c",
    "build": "npm-run-all clean --parallel build:*",

running npm run build works fine and does exactly what is expected. Using yarn, however, fails with a bunch of exceptions.

❯ yarn build
yarn run v1.22.10
$ npm-run-all clean --parallel build:*
Watching /path/to/project and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./.git ; is listed in .gitignore
Found & ignored ./.github ; is listed in .gitignore
Found & ignored ./docs ; is listed in .gitignore
Found & ignored ./node_modules ; is listed in .gitignore
Found & ignored ./src ; is listed in .gitignore
Found & ignored ./CHANGELOG.md ; is listed in .gitignore
Found & ignored ./LICENSE ; is listed in .gitignore
Found & ignored ./README.md ; is listed in .gitignore
Found & ignored ./babel.config.js ; is listed in .gitignore
Found & ignored ./index.js ; is listed in .gitignore
Found & ignored ./jsdoc.json ; is listed in .gitignore
Found & ignored ./package.json ; is listed in .gitignore
Found & ignored ./rollup.config.js ; is listed in .gitignore
Found & ignored ./yarn.lock ; is listed in .gitignore

Starting: clean
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module '/path/to/project/clean'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Interestingly, this only seems to happen if scripts include run-s, run-p or npm-run-all calls. For instance, running simply yarn clean (which invokes rimraf) works, but running yarn run-s clean fails with the same exception shown above.

Using:

❯ node -v
v14.15.4

❯ yarn -v
1.22.10

❯ npm -v
7.4.0
@TreTuna
Copy link

TreTuna commented Mar 17, 2021

It's due to the glob pattern. Yarn is expanding the glob and not sending it to npm-run-all. If you wrap the glob in quotes, it should work.

    "build": "npm-run-all clean --parallel 'build:*'",

See also: #200

@nfantone
Copy link
Author

nfantone commented Mar 18, 2021

@TreTuna It's been a while since I posted this, so I cannot truly confirm what you're saying. But judging from my original comments, that wouldn't explain why yarn run-s clean (which does not set any glob patterns) doesn't work.

Also, the issue you're pointing at is related to yarn v2. My issue is reproducible in 1.22.10.

@snejugal
Copy link

snejugal commented Apr 4, 2021

The error is very similar to mine, except that I'm getting it with npm@7.8.0 (that is, without yarn at all), but on npm@6.14 it works fine:

$ npm --version
7.8.0
$ npm run build:cat

> coreutils@0.0.0 build:cat
> cd src/uu/cat && wasm-pack build && npx pkg2wef

# ...executes successfully

$ npx npm-run-all build:cat
Watching /home/snejugal/projects/wubix-crates/coreutils and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./node_modules ; is listed in .gitignore

Starting: build:cat
node:internal/modules/cjs/loader:928
  throw err;
  ^

Error: Cannot find module '/home/snejugal/projects/wubix-crates/coreutils/build:cat'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
^C # note: it doesn't exit but stuck in some infinite loop wasting CPU time
$ npx npm-run-all --version
v4.1.5
$ npm i -g npm@6

removed 58 packages, changed 11 packages, and audited 436 packages in 6s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ npm --version
6.14.12
$ npx npm-run-all build:cat

> coreutils@0.0.0 build:cat /home/snejugal/projects/wubix-crates/coreutils
> cd src/uu/cat && wasm-pack build && npx pkg2wef

# ...executes successfully as well

$ npx npm-run-all --version
v4.1.5

FWIW, the repo is public: https://gitlab.com/wubix-crates/coreutils (note that if you try to execute npm run build, it's going to compile Rust code to WASM, so for reproduction getting an error like wasm-pack: command not found is enough)

@petermikitsh
Copy link

I ran into this issue with Yarn Classic (v1) and the workaround was to downgrade from npm v7 to npm v6:

npm i -g npm@6

@jamesrweb
Copy link

@petermikitsh worked for me too, any idea why the downgrade is even a solution though?

@kjk7034
Copy link

kjk7034 commented Aug 5, 2021

change from

"build": "npm-run-all clean --parallel build:*",

to

"build": "npm-run-all clean --parallel 'build:*'",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants