Giter Club home page Giter Club logo

Comments (26)

zxdong262 avatar zxdong262 commented on July 23, 2024 1

Deployed, since it is not a generic solution, publised a temp module
electerm/electerm@c064b6a
electerm@52446ec

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024 1

I figured it out. There is a .git in my home directory, which leads to no .git in ~/.npm/_cacache/tmp/git-clonevhihTl.

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024 1

I tried, not working some how, have to use runtime require

The reason is the code runs before window.require is set.

trzsz.js/src/comm.ts

Lines 25 to 34 in 9320e1c

export const isRunningInBrowser = (function() {
try {
if (require.resolve("fs") === "fs") {
require("fs");
return false;
}
} catch (err) {
return true;
}
})();

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;.

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

Try to use the absolute path of Downloads?

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

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.

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

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.

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

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.

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.

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

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.

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

Tried different folder, same result.

Maybe some error in window.showDirectoryPicker with mode readwrite.

return await window.showDirectoryPicker({ id: "trzsz_download", startIn: "downloads", mode: "readwrite" });

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

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').

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

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').

Try this:

window.require = (module) => {
    if (module == "fs") {
        return {}
    }
}

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

Since you set window.require to a function, you should be able to use trzsz.js directly, no need to make a copy.

https://github.com/electerm/electerm/blob/c064b6a581c7c28103d8784437b9492a4f619ee1/src/client/common/pre.js#L165

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

Since you set window.require to a function, you should be able to use trzsz.js directly, no need to make a copy.

https://github.com/electerm/electerm/blob/c064b6a581c7c28103d8784437b9492a4f619ee1/src/client/common/pre.js#L165

I tried, not working some how, have to use runtime require

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

electerm npm install fails for me.

~/workspace/electerm$ npm i
npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated [email protected]: 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! > [email protected] prepare
npm ERR! > husky install
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated [email protected]: 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

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

electerm npm install fails for me.

~/workspace/electerm$ npm i
npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated [email protected]: 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! > [email protected] prepare
npm ERR! > husky install
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated [email protected]: 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?

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

Both 16 and 20 are the same error.
Haven't found a solution that works for me yet.

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

Can you try uninstall your nodejs, install with nvm, then nvm install 16

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024
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.

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

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

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024
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.

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

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.

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

git clone https://github.com/electerm/electerm.git

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

Check that your version of Git, is it greater than 2.9?

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

git version 2.39.2 (Apple Git-143)

from trzsz.js.

lonnywong avatar lonnywong commented on July 23, 2024

Maybe related to apple m1.

from trzsz.js.

zxdong262 avatar zxdong262 commented on July 23, 2024

I tried, not working some how, have to use runtime require

The reason is the code runs before window.require is set.

trzsz.js/src/comm.ts

Lines 25 to 34 in 9320e1c

export const isRunningInBrowser = (function() {
try {
if (require.resolve("fs") === "fs") {
require("fs");
return false;
}
} catch (err) {
return true;
}
})();

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;.

Works!

from trzsz.js.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.