Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after 'node main.js'. #5

Closed
wanxuntong opened this issue Mar 12, 2023 · 5 comments
Closed

Error after 'node main.js'. #5

wanxuntong opened this issue Mar 12, 2023 · 5 comments

Comments

@wanxuntong
Copy link

The following error occurs when running 'node main.js'.
Is there any way to solve it?

`node:internal/modules/cjs/loader:1024
throw err;
^

Error: Cannot find module 'dotenv'
Require stack:

  • I:\aivtuber\AIVTuber-main\TTS\main.js
    �[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)�[39m
    �[90m at Function.Module._load (node:internal/modules/cjs/loader:866:27)�[39m
    �[90m at Module.require (node:internal/modules/cjs/loader:1093:19)�[39m
    �[90m at require (node:internal/modules/cjs/helpers:108:18)�[39m
    at Object. �[90m(I:\aivtuber\AIVTuber-main\TTS\�[39mmain.js:9:1�[90m)�[39m
    �[90m at Module._compile (node:internal/modules/cjs/loader:1191:14)�[39m
    �[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)�[39m
    �[90m at Module.load (node:internal/modules/cjs/loader:1069:32)�[39m
    �[90m at Function.Module._load (node:internal/modules/cjs/loader:904:12)�[39m
    �[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)�[39m {
    code: �[32m'MODULE_NOT_FOUND'�[39m,
    requireStack: [ �[32m'I:\aivtuber\AIVTuber-main\TTS\main.js'�[39m ]
    }`
@ponlponl123
Copy link
Owner

ponlponl123 commented Mar 12, 2023

The log shows that it cannot find the dotenv module to resolve this issue.
You can use the command npm install dotenv to install the dotenv module to fix this problem!

Thanks for the feedback. I will make it even better in the future! 🙂

@wanxuntong
Copy link
Author

It can be installed normally in the system directory, but an error will be reported in the project directory (Google translation)

C:\WINDOWS\system32>npm install dotenv
up to date, audited 2 packages in 2s
found 0 vulnerabilities

I:\aivtuber\AIVTuber-main\TTS>npm install dotenv
npm ERR! code 1
npm ERR! path I:\aivtuber\AIVTuber-main\TTS\node_modules\speaker
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@16.19.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.8 found at "C:\Users\1\AppData\Local\Programs\Python\Python39\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack at D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
npm ERR! gyp ERR! stack at D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack at D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:385:16
npm ERR! gyp ERR! stack at D:\Node\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at D:\Node\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:410:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "D:\Node\node.exe" "D:\Node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd I:\aivtuber\AIVTuber-main\TTS\node_modules\speaker
npm ERR! gyp ERR! node -v v16.19.1
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR! D:\Node\node_cache_logs\2023-03-12T04_23_06_374Z-debug-0.log

@ponlponl123
Copy link
Owner

ponlponl123 commented Mar 12, 2023

#This error message appears to be related to the speaker package in a Node.js project. There are a few different warnings and errors that are shown in the output:

  • Two npm WARN messages are displayed, indicating that two packages (request and querystring) are deprecated and may cause issues in the future. It is recommended to update to the latest versions of these packages, or use alternative packages if possible.

  • The npm ERR! code 1 message indicates that there was an error during the installation or build process of the speaker package.

  • The subsequent output shows the error message that was generated during the build process. It appears to be related to the node-gyp package, which is used for building native Node.js add-ons. The error message suggests that node-gyp was unable to find a compatible version of Visual Studio to use for building the speaker package.

To resolve this issue, there are a few potential steps that could be taken:

  • Update the request and querystring packages to their latest versions or use alternative packages to avoid the deprecation warnings.

  • Ensure that a compatible version of Visual Studio is installed on the system, and that it is properly configured for use with node-gyp. The error message indicates that Visual Studio 2017 or newer is required, and that the "Desktop development with C++" workload needs to be installed. The node-gyp documentation provides more detailed instructions for configuring Visual Studio on Windows: https://github.com/nodejs/node-gyp#on-windows.

  • If the speaker package is not necessary for the project, it could be removed or replaced with an alternative package that does not require native add-ons to be built.

I think this issue is similar to #4, or you can check out Issues #4 !

I think this will solve your problem!

@wanxuntong
Copy link
Author

(Google Translate) After running 'node main.js' appeared

‘listening on localhost:8000
Pronounce by yourself:’

What should I enter?
Enter '123123' and it will appear

No previous file to delete
Error: Command failed: "FFMPEG_PATH" -i "path/to/output.mp3" -acodec pcm_s16le -ac 1 -ar 16000 "path/to/output.wav"
'"FFMPEG_PATH"' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

at ChildProcess.exithandler (node:child_process:402:12)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1100:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) {

code: 1,
killed: false,
signal: null,
cmd: '"FFMPEG_PATH" -i "path/to/output.mp3" -acodec pcm_s16le -ac 1 -ar 16000 "path/to/output.wav"'
}
File saved.
text !== "exit" : Method
node:events:491
throw er; // Unhandled 'error' event
^

Error: ENOENT: no such file or directory, open 'I:\aivtuber\AIVTuber-main\TTS\path\to\output.wav'
Emitted 'error' event on ReadStream instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'I:\aivtuber\AIVTuber-main\TTS\path\to\output.wav'
}

And generated 'output.mp3' under '\TTS\path\to'
Where is the bug?

@ponlponl123
Copy link
Owner

ponlponl123 commented Mar 12, 2023

In line 68 of the main.js file you can try to change from

await fs.unlink('path/to/output.wav', (err) => {
         if (err) console.log('No previous file to delete');
       });

is

try {
         fs.unlinkSync('path/to/output.wav');
       } catch (err) {
         console.log('No previous file to delete');
       }

Oh yes, and you need to change the ffmpeg_path variable to a valid path address like c:/ffmpeg/bin/ffmpeg.exe.

I think this will solve your problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants