Error with npm install opencv
Question: When running "npm install opencv" this is what I get

    
    
        > if not defined npm_config_node_gyp (node "C:\Users\Shaun\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\.
    .\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\Shaun\node_modules\opencv\bui
    ld\opencv\v4.0.0\Release\node-v46-win32-ia32\opencv.node --module_name=opencv --module_path=C:\Users\Shaun\node_module
    s\opencv\build\opencv\v4.0.0\Release\node-v46-win32-ia32 --python=python2.7 --msvs_version=2015 )  else (node  configu
    re --fallback-to-build --module=C:\Users\Shaun\node_modules\opencv\build\opencv\v4.0.0\Release\node-v46-win32-ia32\ope
    ncv.node --module_name=opencv --module_path=C:\Users\Shaun\node_modules\opencv\build\opencv\v4.0.0\Release\node-v46-wi
    n32-ia32 --python=python2.7 --msvs_version=2015 )
    
    Shaun@SHAUN-PC C:\Users\Shaun\node_modules\opencv
    > if not defined npm_config_node_gyp (node "C:\Users\Shaun\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\.
    .\node_modules\node-gyp\bin\node-gyp.js" build --fallback-to-build --module=C:\Users\Shaun\node_modules\opencv\build\o
    pencv\v4.0.0\Release\node-v46-win32-ia32\opencv.node --module_name=opencv --module_path=C:\Users\Shaun\node_modules\op
    encv\build\opencv\v4.0.0\Release\node-v46-win32-ia32 )  else (node  build --fallback-to-build --module=C:\Users\Shaun\
    node_modules\opencv\build\opencv\v4.0.0\Release\node-v46-win32-ia32\opencv.node --module_name=opencv --module_path=C:\
    Users\Shaun\node_modules\opencv\build\opencv\v4.0.0\Release\node-v46-win32-ia32 )
    Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
    C:\Users\Shaun\node_modules\opencv\build\opencv.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.
    Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists
    on disk.
    gyp ERR! build error
    gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Users\Shaun\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\l
    ib\build.js:276:23)
    gyp ERR! stack     at emitTwo (events.js:87:13)
    gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    gyp ERR! System Windows_NT 6.1.7601
    gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Shaun\\AppData\\Roaming\\npm\\node_modules\\n
    pm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\Shaun\\node_modules\\
    opencv\\build\\opencv\\v4.0.0\\Release\\node-v46-win32-ia32\\opencv.node" "--module_name=opencv" "--module_path=C:\\Us
    ers\\Shaun\\node_modules\\opencv\\build\\opencv\\v4.0.0\\Release\\node-v46-win32-ia32"
    gyp ERR! cwd C:\Users\Shaun\node_modules\opencv
    gyp ERR! node -v v4.2.4
    gyp ERR! node-gyp -v v3.2.1
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\Shaun\node_
    modules\opencv\build\opencv\v4.0.0\Release\node-v46-win32-ia32\opencv.node --module_name=opencv --module_path=C:\Users
    \Shaun\node_modules\opencv\build\opencv\v4.0.0\Release\node-v46-win32-ia32' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Shaun\node_modules\opencv\node_modules\node-pre-gyp\
    lib\util\compile.js:83:29)
    node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
    node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
    node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:818:16)
    node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
    node-pre-gyp ERR! System Windows_NT 6.1.7601
    node-pre-gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Shaun\\node_modules\\opencv\\node_mo
    dules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd C:\Users\Shaun\node_modules\opencv
    node-pre-gyp ERR! node -v v4.2.4
    node-pre-gyp ERR! node-pre-gyp -v v0.6.17
    node-pre-gyp ERR! not ok
    Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\Shaun\node_modules\opencv\build\opencv\v4.
    0.0\Release\node-v46-win32-ia32\opencv.node --module_name=opencv --module_path=C:\Users\Shaun\node_modules\opencv\buil
    d\opencv\v4.0.0\Release\node-v46-win32-ia32' (1)
    npm WARN optional Skipping failed optional dependency /node-inspector/biased-opener/x-default-browser/default-browser-
    id:
    npm WARN notsup Not compatible with your operating system or architecture: default-browser-id@1.0.2
    npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Shaun\package.json'
    npm WARN Shaun No description
    npm WARN Shaun No repository field.
    npm WARN Shaun No README data
    npm WARN Shaun No license field.
    npm ERR! Windows_NT 6.1.7601
    npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Shaun\\AppData\\Roaming\\npm\\node_modules\\npm\
    \bin\\npm-cli.js" "install" "opencv"
    npm ERR! node v4.2.4
    npm ERR! npm  v3.5.3
    npm ERR! code ELIFECYCLE
    
    npm ERR! opencv@4.0.0 install: `node-pre-gyp install --fallback-to-build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the opencv@4.0.0 install script 'node-pre-gyp install --fallback-to-build'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the opencv package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     node-pre-gyp install --fallback-to-build
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs opencv
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls opencv
    npm ERR! There is likely additional logging output above.
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     C:\Users\Shaun\npm-debug.log
    

I've been trying bit by bit to work through each error and I seriously just
cannot figure out what's wrong here.

I'm using OpenCV as part of a College project to use in a web app. It anyone
can help me with this please do.

Thank you.


Answer: I had the same issue. I solved it by using OpenCV 2.4

