'Truffle migrate and truffle install error

I keep getting this error. When I try truffle migrate --reset

    node:internal/modules/cjs/loader:936
  throw err;
  ^

    Error: Cannot find module 'C:\Users\merta\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js'
        at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
        at Function.Module._load (node:internal/modules/cjs/loader:778:27)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
        at node:internal/main/run_main_module:17:47 {
      code: 'MODULE_NOT_FOUND',
      requireStack: []
    }

I am getting the error.

When I try to install truffle, I get the following error via yarn or npm

gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | win32 | x64 gyp info find Python using Python version 3.10.2 found at "C:\Users\merta\AppData\Local\Programs\Python\Python310\python.exe" gyp ERR! find VS gyp ERR! find VS msvs_version not set from command line or npm config gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details gyp ERR! find VS looking for Visual Studio 2015 gyp ERR! find VS - not found gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 gyp ERR! find VS gyp ERR! find VS ************************************************************** gyp ERR! find VS You need to install the latest version of Visual Studio gyp ERR! find VS including the "Desktop development with C++" workload. gyp ERR! find VS For more information consult the documentation at: gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows gyp ERR! find VS ************************************************************** gyp ERR! find VS gyp ERR! configure error gyp ERR! stack Error: Could not find any Visual Studio installation to use gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstu dio.js:122:47) gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16 gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib \find-visualstudio.js:363:14) gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14 gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16 gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7 gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16 gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) gyp ERR! stack at ChildProcess.emit (node:events:520:28) gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) gyp ERR! System Windows_NT 10.0.19044 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\
\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\merta\\Downloads\\Compressed\\fr ontend_base_dapp-main\\node_modules\\sqlite3\\lib\\binding\\node-v93-win32-x64\\node_sqlite3.node" "--module_name=node_sql ite3" "--module_path=C:\\Users\\merta\\Downloads\\Compressed\\frontend_base_dapp-main\\node_modules\\sqlite3\\lib\\b inding\\node-v93-win32-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93" gyp ERR! cwd C:\Users\merta\Downloads\Compressed\frontend_base_dapp-main\node_modules\sqlite3 gyp ERR! node -v v16.14.0 gyp ERR! node-gyp -v v8.4.1 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\merta\Downloads\Compr essed\frontend_base_dapp-main\node_modules\sqlite3\lib\binding\node-v93-win32-x64\node_sqlite3.node --module_name=node_sqlite3 -- module_path=C:\Users\merta\Downloads\Compressed\frontend_base_dapp-main\node_modules\sqlite3\lib\binding\node-v93-win32-x64 -- napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) node-pre-gyp ERR! stack at ChildProcess. (C:\Users\merta\Downloads\Compressed\frontend_base_dapp-main\node_modules
\node-pre-gyp\lib\util\compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (node:events:520:28) node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) Done in 367.51s.

Node.js, VS, Python etc. all apps are installed. I tried with VScode and Atom but I get the same error.



Solution 1:[1]

I faced the same issue. Managed to solve first uninstalling truffle 'npm uninstall -g truffle' (check every single route/folder on your sistem related) then using previous node version v14.17.3 to install it again. Make sure you follow all the process being the system admin or having permission.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arthur