BYVoid / OpenCC

Conversion between Traditional and Simplified Chinese
https://opencc.byvoid.com/
Apache License 2.0
8.47k stars 982 forks source link

nodejs: Cannot install opencc@1.1.8 #908

Open Cerallin opened 2 weeks ago

Cerallin commented 2 weeks ago

This is because data/scripts are missing, and not uploaded to npm.

Part of the logs:

...
npm error python: can't open file '/workspaces/website/node_modules/opencc/data/scripts/merge.py': [Errno 2] No such file or directory
npm error make: *** [dicts.target.mk:104: Release/TWPhrases.txt] Error 2
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm error gyp ERR! System Linux 6.5.0-1025-azure
npm error gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--module=/workspaces/website/node_modules/opencc/build/Release/opencc.node" "--module_name=opencc" "--module_path=/workspaces/website/node_modules/opencc/build/Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v115"
npm error gyp ERR! cwd /workspaces/website/node_modules/opencc
npm error gyp ERR! node -v v20.18.0
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok 
npm error node-pre-gyp ERR! build error 
npm error node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --module=/workspaces/website/node_modules/opencc/build/Release/opencc.node --module_name=opencc --module_path=/workspaces/website/node_modules/opencc/build/Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v115' (1)
npm error node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/workspaces/website/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm error node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
npm error node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm error node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm error node-pre-gyp ERR! System Linux 6.5.0-1025-azure
npm error node-pre-gyp ERR! command "/usr/bin/node" "/workspaces/website/node_modules/.bin/node-pre-gyp" "rebuild"
npm error node-pre-gyp ERR! cwd /workspaces/website/node_modules/opencc
npm error node-pre-gyp ERR! node -v v20.18.0
npm error node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm error node-pre-gyp ERR! not ok
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-10-13T06_12_36_082Z-debug-0.log
BYVoid commented 1 week ago

does python exist?

Cerallin commented 1 week ago

does python exist?

At first I executed npm install, and it reported an error: cannot find python. So I made a soft link ln -s /usr/bin/python3 /bin/python. Then npm install again.

This is where we are now. (Is python3 the right version?)

tomcatliu2016 commented 1 week ago

I have fixed the issue and created a pull request (PR): https://github.com/BYVoid/OpenCC/pull/911 As a temporary workaround until the npm package is updated, you can do the following:

  1. Clone my forked repository on the fix_npm_install_error branch: https://github.com/tomcatliu2016/OpenCC/tree/fix_npm_install_error
  2. Navigate to the OpenCC directory and create a tarball:
cd OpenCC
npm pack
  1. In your Node.js project, install the tarball:
    npm install /path/to/tarball

This method serves as a temporary solution until the npm package is officially updated.