0

I am on Windows 10.
Node Js version V10.16.3 is successfully installed. Npm version 9.x ok also.

I was working for several weeks on a vuejs project using Visual Studio Code.

Suddenly 2 days ago, the npm start command stopped working.

After investigation and having deinstalled and reinstalled nodejs several times (with deletion of directories), I keep ending up with the same problem I'm describing below:

  1. Nodejs REPL console is working fine. When I type process.version > it displays V10.16.3

  2. node -v or node --version display nothing but a blank line in the cmd window.

    node test.js (console.log("hello");) does nothing (no execution at all), except printing a blank line.

    If I type node test.js > test.log: nothing is written to test.log.

  3. npm -v or npm --help open several extra windows in the cmd window.

    The 1st extra window is titled "C:\Program Files\nodejs" and closes straight away.
    The 2nd extra window is titled "npm" and closes straight away.

    Then the prompt goes back to the current cmd window where I typed the command npm --version or -v.

    Then another cycle starts with:

    The 1st extra window is titled "C:\Program Files\nodejs" and closes straight away.
    The 2nd extra window is titled "npm" and closes straight away.

    And finally it comes back to the current cmd window with no output at all except for a blank line.

    Sometimes, I can see the version number "9.x" being displayed in one of the npm titled window.

    npm -list does the same with opening of the 4 successive windows, and a list of node modules is displayed in the last one, titled "npm", before the window closes.

  4. I checked npm.cmd and it is OK

    When I type node "C:\Program Files\\node_modules\npm\bin\npm-cli.js" -v, it displays nothing but a blank line.

  5. I read all questions and answers in stackoverflow but none is related to my case except this one: npm -version displays nothing, but there is no solution provided.

Can someone help me, please?

C:\Program Files\nodejs> node -v
C:\Program Files\nodejs> npm -v
C:\Program Files\nodejs> node "C:\Program Files\\node_modules\npm\bin\npm-cli.js" -v

I expect to display node version and npm version to be displayed in the current cmd line and I expect node test.js to work and get my "hello" as it was working 2 days ago...

I provide somme complements and details with some screenshots :

1) Node console REPL Node console REPL works correctly

2) Cygwin console Node works with cygwin

3) Powershell console Node -v, npm -v, node script.js execute but in a temporary separate popup window > Before this bug with node cmd > all displays were output directly in the console without popup window

4) node cmd window Nodejs command prompt run by node.cmd script no longer works > no version number is displayed. npm command open multiple popup windows with execution of npm but terminates with node error

11 silly lifecycle projet-test@1.0.0~dev: Returned: code: 9 signal: null 12 info lifecycle projet-test@1.0.0~dev: Failed to exec dev script 13 verbose stack Error: projet-test@1.0.0 dev: webpack-dev-server --inline --progress --config build/webpack.dev.conf.js 13 verbose stack Exit status 9 13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:210:5) 13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:210:5) 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

  • 1
    `npm`'s last version is 6.11.3. You cannot have installed NPM 9.x. Otherwise, I highly suggest using [`nvm`](https://github.com/coreybutler/nvm-windows) (Node Version Manager) for installing or updating node – Seblor Sep 28 '19 at 19:05
  • You are right about npm version > it is 6.4.1 – Dominique REYREN Oct 02 '19 at 14:27

2 Answers2

0

I think you should completely uninstall Nodejs and NPM and reinstall. Some files might have been corrupted.

enter image description here

IMP: Don't use NPM version higher than 6.11.3

Alternatively, if you don't want to uninstall select repair option by running installer again

Sandeep Patel
  • 4,815
  • 3
  • 21
  • 37
  • Thank You., But I already uninstall and reinstall Nodejs several times. That pb is no related to npm but to nodejs in command mode > node test.js display a blank line. – Dominique REYREN Sep 28 '19 at 21:34
  • If nothing is working you take back up of code and do `Open System Restore` for a date prior to the issue – Sandeep Patel Sep 29 '19 at 08:36
  • Thank You again. I did it but no change. If I type the command npm install -g npm-windows-upgrade, I can see in th extra npm window opended the dowload and install . The when I run npm-windows-updgrade I get no prompt to choose a version but only a blank line. it seems that all output are done in the background but not in the current cmd window. – Dominique REYREN Sep 29 '19 at 14:30
  • @DominiqueREYREN have you done `Windows system restore` properly? It should be working after that. I am clueless now what might be causing the issue. – Sandeep Patel Sep 29 '19 at 14:39
0

I found a aworkaround doing a silly thing :

  • I renamed node.exe in C:\Program Files\Nodejs as mynode.exe
  • I modified nodevars.bat, npm.cmd by replacing node.exe by mynode.exe in each node.exe call
  • I wrote a simple node.cmd file containing these lines and placed in C:\Program Files\ directory:

    :: Created by DR
    @ECHO OFF
    
    SETLOCAL
    
    SET "NODE_EXE=%~dp0\mynode.exe"
    IF NOT EXIST "%NODE_EXE%" (
    

    SET "NODE_EXE=mynode" )

    "%NODE_EXE%" %*

running node -v being node.cmd works

I know it is a stupid method but it works in my very specific case. It means that 'something' prevents to run node.exe in command line but allows node.cmd that launchs mynode.exe.

I someone could explain/found out what is wrong in my windows configuration, I would be very thankful.

( I checked for any other node.exe, checked path and register, install/uninstall node, etc. BUT, I always stick with the same probleme although running node.exe in command line was working vey well before I encountered the crash of eslint when editing a simple vue.js file with visual studio code editor. since that there is a parameter in my windows confinguration that blocks node.exe in dos command line and only within command line window. For recall, node -v (with node.exe) works well in cygwin...