Closed zxdong262 closed 12 months ago
Try to use the absolute path of Downloads
?
Oh, do you change it to browser mode? Chrome does not allow writing to system directories. The Downloads
is one of the system directories. Try to make a subdirectory in Downloads
, and save to that subdirectory should work.
Using trzsz in the browser is very limited, and the user experience will be poor. It would be much better if there is a way to provide fs
api to trzsz.
Oh, do you change it to browser mode? Chrome does not allow writing to system directories. The
Downloads
is one of the system directories. Try to make a subdirectory inDownloads
, and save to that subdirectory should work.
Tried different folder, same result, since in newer electron, can not expose fs directly in preload.js, wondering if we can expose fs api in brower mode through ipc, I am doing some experiments.
trzsz just need a few functions in fs
. check https://github.com/trzsz/trzsz.js/blob/main/src/nodefs.ts. I want to change all of them to async, and make it replaceable.
Tried different folder, same result.
Maybe some error in window.showDirectoryPicker
with mode readwrite
.
https://github.com/trzsz/trzsz.js/blob/9320e1ccc6663bb628821ae871c5897f986680e2/src/browser.ts#L188
I tried, after provide all fs/path functions in ipc mode and provide a proper window.require function, it would work, just need replace fs.
to a runtime require('fs')
.
I tried, after provide all fs/path functions in ipc mode and provide a proper window.require function, it would work, just need replace
fs.
to a runtimerequire('fs')
.
Try this:
window.require = (module) => {
if (module == "fs") {
return {}
}
}
Deployed, since it is not a generic solution, publised a temp module https://github.com/electerm/electerm/commit/c064b6a581c7c28103d8784437b9492a4f619ee1 https://github.com/electerm/trzsz.js/commit/52446ecc24f84e8a2a75b8989575c5ffc1e96c50
Since you set window.require
to a function, you should be able to use trzsz.js
directly, no need to make a copy.
Since you set
window.require
to a function, you should be able to usetrzsz.js
directly, no need to make a copy.
I tried, not working some how, have to use runtime require
electerm npm install
fails for me.
~/workspace/electerm$ npm i
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /opt/homebrew/Cellar/node/20.5.1/bin/node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/lonnywong/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! > vscode-icons@12.5.0 prepare
npm ERR! > husky install
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm ERR! .git can't be found (see https://git.io/Jc3F9)
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /Users/lonnywong/.npm/_cacache/tmp/git-clonevhihTl
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c husky install
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in: /Users/lonnywong/.npm/_logs/2023-08-29T07_30_41_496Z-debug-0.log
electerm
npm install
fails for me.~/workspace/electerm$ npm i npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates. npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. npm ERR! code 1 npm ERR! git dep preparation failed npm ERR! command /opt/homebrew/Cellar/node/20.5.1/bin/node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/lonnywong/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm ERR! > vscode-icons@12.5.0 prepare npm ERR! > husky install npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm ERR! .git can't be found (see https://git.io/Jc3F9) npm ERR! npm ERR! code 1 npm ERR! npm ERR! path /Users/lonnywong/.npm/_cacache/tmp/git-clonevhihTl npm ERR! npm ERR! command failed npm ERR! npm ERR! command sh -c husky install npm ERR! npm ERR! npm ERR! A complete log of this run can be found in: /Users/lonnywong/.npm/_logs/2023-08-29T07_30_41_496Z-debug-0.log
nodejs 16?
Both 16 and 20 are the same error. Haven't found a solution that works for me yet.
Can you try uninstall your nodejs, install with nvm, then nvm install 16
brew uninstall node
brew install node@16
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
node -v
v16.20.2
npm -v
8.19.4
Same error for me.
I mean use nvm
brew uninstall node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
nvm install 16
Also, could try npm cache clean --force
brew uninstall --force node
brew uninstall --force node@16
brew install nvm
mkdir ~/.nvm
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
nvm install 16
npm cache clean --force
node -v
v16.20.2
npm -v
8.19.4
npm i
Same error.
did you clone the electem repo or download as https?
gpt4 gives this:
The error message indicates that there's an issue with Husky, a tool used for managing git hooks. The error message .git can't be found suggests that Husky is unable to find the .git directory in your project.
Here are some things you can try:
Ensure you're in a Git repository: Husky requires your project to be a Git repository. You can initialize it as a Git repository by running git init in the root of your project if it's not already one.
Try reinstalling Node modules: Sometimes, deleting node_modules and reinstalling can help resolve issues related to dependencies:
bash
rm -rf node_modules
npm install
Try updating Husky: It's possible that the version of Husky being used is outdated or has known issues. Try updating it:
bash
npm uninstall husky
npm install --save-dev husky@latest
Manually run husky install: Try manually running the command that seems to be causing the error:
bash
npx husky install
Check global npm cache: There might be some corruption or issues with your global npm cache, you could try clearing it with npm cache clean --force.
Check Node and npm versions: Ensure you're using up-to-date versions of Node.js and npm, as older versions may have compatibility issues with current packages.
If none of these suggestions work, please provide additional information about your development environment such as operating system, Node.js version, npm version etc., so I could provide more specific advice.
git clone https://github.com/electerm/electerm.git
Check that your version of Git, is it greater than 2.9?
git version 2.39.2 (Apple Git-143)
Maybe related to apple m1.
I figured it out. There is a .git
in my home directory, which leads to no .git
in ~/.npm/_cacache/tmp/git-clonevhihTl
.
I tried, not working some how, have to use runtime require
The reason is the code runs before window.require
is set.
https://github.com/trzsz/trzsz.js/blob/9320e1ccc6663bb628821ae871c5897f986680e2/src/comm.ts#L25-L34
Try move window.require = require;
to another source file, and import it before import { TrzszFilter } from "trzsz";
.
And add window.require.resolve = (name) => name;
after window.require = require;
.
I tried, not working some how, have to use runtime require
The reason is the code runs before
window.require
is set.https://github.com/trzsz/trzsz.js/blob/9320e1ccc6663bb628821ae871c5897f986680e2/src/comm.ts#L25-L34
Try move
window.require = require;
to another source file, and import it beforeimport { TrzszFilter } from "trzsz";
.And add
window.require.resolve = (name) => name;
afterwindow.require = require;
.
Works!
Any clue how to fix it?