node icon indicating copy to clipboard operation
node copied to clipboard

EINVAL errors (events.js:160) with Node 7.1.0 on Windows 10

Open mischah opened this issue 10 years ago • 69 comments

  • Version: 7.1.0
  • Platform: Windows 10
  • Subsystem: Events

Hej there,

several users have problems with different packages running node 7.1.0 on Windows 10:

  • https://github.com/mochajs/mocha/issues/2577
  • https://github.com/facebook/react-native/issues/10824
  • https://github.com/electron/electron/issues/7919
  • https://github.com/yeoman/yo/issues/485
  • https://github.com/yeoman/yo/issues/486

All of them seem to have the following in common:

  • It used to work with node 7.0.0 and stopped working with 7.1.0
  • A similiar error with different stacktrace:
events.js:160
      throw er; // Unhandled 'error' event

Error: write EINVAL

Could you enlighten us? Is it a regression in Node.js?

Thanks, Michael

mischah avatar Nov 10 '16 11:11 mischah

@kyrylkov yes. Thanks!

santigimeno avatar Nov 28 '16 20:11 santigimeno

@santigimeno Win64 Node.js v7.2.1-pre built with https://github.com/libuv/libuv/pull/1143 works fine with our webpack /webpack-dev-server config and mocha tests.

skcc75 avatar Nov 28 '16 22:11 skcc75

@kyrylkov thanks for the feedback!

santigimeno avatar Nov 29 '16 09:11 santigimeno

I update node from 7.1.0 to 7.2.1 .. and solved the problem

mcianc avatar Dec 14 '16 14:12 mcianc

We still have a problem on Windows 10 (x64) when trying to "spawn" a child process with ESLint. We have tried 2 NodeJS versions:

  1. node-v6.9.5-x64:
C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint src
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
  1. node-v7.5.0-x64:
C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint src
events.js:161
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint ENOENT
    at exports._errnoException (util.js:1023:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:418:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:533:3

Test script: test.js

const fs = require('fs');
const { spawn } = require('child_process');
const ESLINT_PATH = path.resolve(__dirname, './node_modules/.bin/eslint');

spawn(ESLINT_PATH, ["src"]);

We are using ESLint 1.10.3 - yes, it's quite old version but it works just fine without "spawn" call on both NodeJS versions above. By some reasons in our build script we need to run ESLint as child process, on the OSX there are no such problems, the issue is reproducible only on windows machines.

Does anyone know how we can handle it?

pavelkornev avatar Feb 16 '17 08:02 pavelkornev

Hi,

I am still experiencing the EINVAL issues. Is there a work around for this?

OS: Windows 7 Node: v7.8.0x64 Standard command prompt

Code:

'use strict'

const readline = require('readline')

let uid = ''

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout // note, it does not throw the exception if i remove the output
})

rl.question('Enter database Username: ', (name) => {
  uid = name
  rl.close()
})

Error:

Enter database Username: events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: read EINVAL
    at exports._errnoException (util.js:1034:11)
    at TTY.onread (net.js:580:26)

Mac-lp3 avatar Apr 04 '17 20:04 Mac-lp3

Installing LTS node version and reinstaling vue-cli solved problem.

ulou avatar May 24 '17 17:05 ulou

I'm experiencing this with node 9.5.0.

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;P:\PROJECT\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files\Docker\Docker\Resources\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\bin;C:\Program Files (x86)\Skype\Phone\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\HashiCorp\Vagrant\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Go\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\user\Dropbox\Development\PHP\interpreter\7.1;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Roaming\Composer\vendor\bin;C:\Users\user\go\bin;C:\Users\user\AppData\Local\.meteor\;C:\Users\user\AppData\Roaming\npm;C:\Users\user\AppData\Local\Yarn\bin
9 verbose lifecycle @~start: CWD: P:\PROJECT
10 silly lifecycle @~start: Args: [ '/d /s /c', 'ts-node webpack.server.ts' ]
11 silly lifecycle @~start: Returned: code: 1  signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `ts-node webpack.server.ts`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:160:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:160:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid @
15 verbose cwd P:\PROJECT
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v9.5.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `ts-node webpack.server.ts`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

thasmo avatar Feb 17 '18 17:02 thasmo

Downgarding node version worked for me

Nabila-Rafi avatar Aug 29 '20 01:08 Nabila-Rafi