OpenCC
OpenCC copied to clipboard
Win users can't use yarn to install the Node version if older version of node-gyp is installed
Windows users can't yarn add the Node version of opencc, if an older version of node-gyp (for example, v3.8.0) is among the existent dependencies (or dependencies of dependencies).
My environment:
- OS: Windows 10
- Node: 12.18.1
- yarn: 1.22.5
I've also tested other environments:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10.x, 12.x, 15.x]
command: [yarn, npm i]
with GitHub Actions CI here: https://github.com/tomchen/opencc-nodegyp-test/actions/runs/451084285
No problem in Ubuntu and MacOS, or in Windows with npm (but got some warnings).
And the latest version v7.1.0 of node-gyp has no problem (with yarn) either.
To reproduce:
Create an empty folder, inside the folder, create a package.json:
{
"name": "test",
"dependencies": {
"node-gyp": "^3.8.0"
}
}
Then run
yarn
All good. Then:
yarn add opencc
No luck, it fails, on my machine, it shows:
yarn add v1.22.5
warning package.json: No license field
warning package-lock.json found. Your project contains lock files generated by tools
other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning test: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error C:\Users\Chen\Desktop\test\node_modules\opencc: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild
Arguments:
Directory: C:\Users\Chen\Desktop\test\node_modules\opencc
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | ia32
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release\opencc.node" (not found)
node-pre-gyp http GET https://github.com/BYVoid/OpenCC/releases/download/1.1.1/opencc-v1.1.1-node-v72-win32-ia32.tar.gz
node-pre-gyp http 404 https://github.com/BYVoid/OpenCC/releases/download/1.1.1/opencc-v1.1.1-node-v72-win32-ia32.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/BYVoid/OpenCC/releases/download/1.1.1/opencc-v1.1.1-node-v72-win32-ia32.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/BYVoid/OpenCC/releases/download/1.1.1/opencc-v1.1.1-node-v72-win32-ia32.tar.gz
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Chen\.pyenv\pyenv-win\shims\python.BAT -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print \s.
gyp ERR! stack ^
gyp ERR! stack SyntaxError: unexpected character after line continuation character
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:303:12)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Chen\\Desktop\\test\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build"
"--module=C:\\Users\\Chen\\Desktop\\test\\node_modules\\opencc\\build\\Release\\opencc.node" "--module_name=opencc" "--module_path=C:\\Users\\Chen\\Desktop\\test\\node_modules\\opencc\\build\\Release" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Users\Chen\Desktop\test\node_modules\opencc
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files (x86)\nodejs\node.exe C:\Users\Chen\Desktop\test\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release\opencc.node --module_name=opencc --module_path=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\Chen\Desktop\test\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Chen\\Desktop\\test\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\Chen\Desktop\test\node_modules\opencc
node-pre-gyp ERR! node -v v12.18.1
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files (x86)\nodejs\node.exe C:\Users\Chen\Desktop\test\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release\opencc.node --module_name=opencc --module_path=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | ia32
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Chen\.pyenv\pyenv-win\shims\python.BAT -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print \s.
gyp ERR! stack ^
gyp ERR! stack SyntaxError: unexpected character after line continuation character
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:303:12)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Chen\\Desktop\\test\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--module=C:\\Users\\Chen\\Desktop\\test\\node_modules\\opencc\\build\\Release\\opencc.node" "--module_name=opencc" "--module_path=C:\\Users\\Chen\\Desktop\\test\\node_modules\\opencc\\build\\Release" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Users\Chen\Desktop\test\node_modules\opencc
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files (x86)\nodejs\node.exe C:\Users\Chen\Desktop\test\node_modules\node-gyp\bin\node-gyp.js configure --module=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release\opencc.node --module_name=opencc --module_path=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\Chen\Desktop\test\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Chen\\Desktop\\test\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "rebuild"
node-pre-gyp ERR! cwd C:\Users\Chen\Desktop\test\node_modules\opencc
node-pre-gyp ERR! node -v v12.18.1
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files (x86)\nodejs\node.exe C:\Users\Chen\Desktop\test\node_modules\node-gyp\bin\node-gyp.js configure --module=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release\opencc.node --module_name=opencc --module_path=C:\Users\Chen\Desktop\test\node_modules\opencc\build\Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
I don't know if you are gonna "fix" it or not, you see it's a Win+yarn-only issue and updating to the latest version of node-gyp can solve the problem. But On the other hand many packages use older versions of node-gyp, for example, the popular node-sass version 4.x.x (the latest 5.0.0 released in Oct 2020 has no problem since it switched to the latest version of node-gyp), which many projects and packages are still using today.
I don't have the environment to reproduce the problem. I am also unsure if I can fix it, because the error looks totally unrelated to OpenCC.
Does npm work?
[4/4] 🔨 Building fresh packages... [1/8] ⠄ fsevents [2/8] ⠄ opencc [-/8] ⠄ waiting... [-/8] ⡀ waiting... error /Users/xxx/Desktop/ddd/node_modules/opencc: Command failed. Exit code: 1 Command: node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild Arguments: Directory: /Users/xxx/Desktop/ddd/node_modules/opencc
node: v12.12.0 yarn:v1.22.10
macOS 10.15.7 (catalina)
Same here.
[4/4] Building fresh packages... [-/14] ⡀ waiting... [12/14] ⡀ opencc [-/14] ⡀ waiting... [11/14] ⡀ ejs error /home/UserName/ProjectName//node_modules/opencc: Command failed. Exit code: 1 Command: node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild
node -v
v16.12.0
yarn -v
1.22.11
Ubuntu 20.04 LTS