yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.43k stars 2.72k forks source link

--prod mode randomly fails #1462

Open hyperknot opened 7 years ago

hyperknot commented 7 years ago

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

What is the current behavior? --prod mode randomly fails installing node-sass. How frequently depends on the JSON file.

The missing package also depends on what is the contents of the JSON file (try removing random lines). It seems to be related to devDependencies being present. With no devDependencies I couldn't reproduce.

Some error messages:

yarn install v0.16.1
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
[1/2] ⠈ node-sass
[2/2] ⠈ fsevents: node-pre-gyp info validate Running test command: '/usr/local/Cellar/node4-lts/4.6.1/bin/
[-/2] ⠈ waiting...
[-/2] ⠈ waiting...
error /Users/user/nonsync/temp/node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/install.js
Directory: /Users/user/nonsync/temp/node_modules/node-sass
Output:
module.js:327
    throw err;
    ^

Error: Cannot find module 'generate-object-property'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/user/nonsync/temp/node_modules/is-my-json-valid/index.js:1:76)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
yarn install v0.16.1
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
[1/2] ⠐ node-sass
[2/2] ⠐ fsevents: ok
[-/2] ⠐ waiting...
[-/2] ⠐ waiting...
error /Users/user/nonsync/temp/node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/install.js
Directory: /Users/user/nonsync/temp/node_modules/node-sass
Output:
module.js:327
    throw err;
    ^

Error: Cannot find module 'string-width'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/user/nonsync/temp/node_modules/wide-align/align.js:2:19)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
yarn install v0.16.1
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
[1/1] β’€ node-sass
[-/1] β’€ waiting...
[-/1] β’€ waiting...
[-/1] β’€ waiting...
error /Users/user/nonsync/temp/node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/install.js
Directory: /Users/user/nonsync/temp/node_modules/node-sass
Output:
module.js:327
    throw err;
    ^

Error: Cannot find module 'pinkie-promise'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/user/nonsync/temp/node_modules/har-validator/lib/index.js:3:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

If the current behavior is a bug, please provide the steps to reproduce. Try to yarn install --prod the following package.json:

fails 1 out of 5 times:

{
  "private": true,
  "dependencies": {
    "aliasify": "2.x",
    "autoprefixer": "6.x",
    "browserify": "13.x",
    "clean-css": "3.x",
    "node-sass": "3.x",
    "postcss-cli": "2.x",
    "uglifyify": "3.x"
  },
  "devDependencies": {
    "eslint": "3.x"
  }
}

fails 9 out of 10 times:

{
  "private": true,
  "dependencies": {
    "aliasify": "2.x",
    "autoprefixer": "6.x",
    "browserify": "13.x",
    "clean-css": "3.x",
    "node-sass": "3.x",
    "postcss-cli": "2.x",
    "uglifyify": "3.x"
  },
  "devDependencies": {
    "eslint": "3.x",
    "eslint-config-standard": "6.x",
    "eslint-plugin-promise": "3.x",
    "eslint-plugin-standard": "2.x",
    "madge": "1.x",
    "standard": "8.x",
    "stylelint": "7.x",
    "stylelint-config-standard": "14.x"
  }
}

Generally the more packages the higher chance of failing.

What is the expected behavior? It should install the non-dev dependencies without failing.

Please mention your node.js, yarn and operating system version. node v4.6.1, yarn 0.16.1, OS X 10.11.6

bdentino commented 7 years ago

I'm able to reproduce this 100% of the time using the given dependencies simply by running rm -rf node_modules/ yarn.lock && yarn install --prod.

patrickomeara commented 7 years ago

I'm hitting this as well. yarn install works fine but yarn install --production fails.

{
  "private": true,
  "dependencies": {
    "bootstrap-sass": "^3.3.7",
    "browserify": "^13.1.1",
    "gulp": "^3.9.1",
    "gulp-coffee": "^2.3.2",
    "gulp-concat": "^2.6.0",
    "gulp-cssnano": "^2.1.2",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.3.2",
    "gulp-uglify": "^2.0.0",
    "gulp-util": "^3.0.7",
    "lodash": "^4.16.1",
    "run-sequence": "^1.2.2",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.1.0"
  },
  "devDependencies": {
    "jest-cli": "^16.0.2"
  }
}

output

yarn install v0.16.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /src/node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/install.js
Directory: /src/node_modules/node-sass
Output:
module.js:474
    throw err;
    ^

Error: Cannot find module 'string-width'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/src/node_modules/wide-align/align.js:2:19)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
carlitux commented 7 years ago

This was closed with no solution. Is not yarn ready to use on production?

hyperknot commented 7 years ago

This one is still open, a linked issue was closed.

iturgeon commented 7 years ago

Just chiming in to say that I too ran into this with node-sass using the production flag

error /var/www/node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/install.js
Directory: /var/www/node_modules/node-sass
Output:
module.js:474
    throw err;
    ^
    Error: Cannot find module 'pinkie-promise'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/www/node_modules/har-validator/lib/index.js:3:15)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)", "stdout": "yarn install v0.16.1
    info No lockfile found.
patrickomeara commented 7 years ago

@iturgeon Can you provide the relevant info from your package.json? I am going to dig deeper into this one for a solution.

iturgeon commented 7 years ago

Will do, trying to reduce it down at the moment. It looks like if I run yarn install --production again after it fails, well, it works.

iturgeon commented 7 years ago

After running it 30 or so times (clearing node_modules dir after each) the failure seems intermittent.

Heres a clipped dep/devdep list that will produce the Error: Cannot find module 'pinkie-promise' error I listed above

{
  "dependencies": {
    "gulp": "^3.8.11",
    "gulp-coffee": "^2.3.1",
    "gulp-concat": "^2.5.2",
    "gulp-minify-css": "^1.2.1",
    "gulp-ng-annotate": "^0.5.2",
    "gulp-sass": "^2.0.4"
  },
  "devDependencies": {
    "gulp-livereload": "^3.8.0",
    "gulp-watch": "^4.1.1"
  }
}
viridia commented 7 years ago

If I delete node_modules and run "yarn install --prod" it always fails. However, if I run it a second time after the failure, it works.

rwillrich commented 7 years ago

We are still having this problem. The temporary solution for us was to run without the --prod flag until the problem is solved. But with the release of 0.17.x, yarn have started to use NODE_ENV=production (see https://github.com/yarnpkg/yarn/blob/v0.17.0/src/cli/commands/install.js#L110) to set this option, what made our deploys to fail again.

There are any solutions to this problem yet?

pfazzino commented 7 years ago

Still got this problem with 0.18.1 and node-sass.

  1. rm yarn.lock && yarn cache clean && rm -rf node_modules
  2. yarn --production, works.
  3. rm -rf node_modules
  4. yarn --production
error .../node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/install.js
Directory: .../node_modules/node-sass
Output:
module.js:327
    throw err;
    ^

Error: Cannot find module 'code-point-at'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (.../node_modules/string-width/index.js:3:19)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
willdurand commented 7 years ago

The hackathon-starter project cannot be easily deployed to Heroku (for instance) because of that, with the exact same behavior.

pfazzino commented 7 years ago

Any update on this issue? Still failing with 0.19.1 on ubuntu

ghost commented 7 years ago

Getting this error too.