Ошибка сборки Nextron
Пытаюсь использовать ssh2-sftp-client вместе с Nextron, все отлично работает до тех пор пока не доходит до сборки самой программы.
При сборке программы с помощью команды
nextron build --win --x64
Выдает следующее:
> [email protected] build
> nextron build
[nextron] Clearing previous builds
[nextron] Building renderer process
warn - Invalid next.config.js options detected:
- The value at .images.path must be 1 character or more but it was 0 characters.
See more info here: https://nextjs.org/docs/messages/invalid-next-config
info - Linting and checking validity of types
info - Using wasm build of next-swc
warn - Attempted to load @next/swc-win32-x64-gnu, but it was not installed
warn - Attempted to load @next/swc-win32-x64-msvc, but it was not installed
info - Creating an optimized production build
Failed to compile.
../node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node
../node_modules/ssh2/lib/protocol/crypto.js
../node_modules/ssh2/lib/client.js
../node_modules/ssh2/lib/index.js
../node_modules/ssh2-sftp-client/src/index.js
../main/client.jsx
../main/actions.js
> Build failed because of webpack errors
package.json
{
"private": true,
"name": "program",
"description": "",
"version": "1.0.0",
"author": "",
"main": "app/background.js",
"scripts": {
"dev": "nextron",
"build": "nextron build",
"postinstall": "electron-builder install-app-deps",
"build:win32": "nextron build --win --ia32",
"build:win64": "nextron build --win --x64"
},
"dependencies": {
"bootstrap": "^5.3.2",
"electron-serve": "^1.1.0",
"electron-store": "^8.1.0",
"find-process": "^1.4.7",
"react-bootstrap-icons": "^1.10.3",
"ssh2": "^1.15.0",
"ssh2-sftp-client": "^10.0.3"
},
"devDependencies": {
"@types/node": "^20.11.16",
"@types/react": "18.2.55",
"css-loader": "^6.10.0",
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"next": "^12.3.4",
"nextron": "^8.5.0",
"node-loader": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.70.0",
"sass-loader": "^14.1.0",
"typescript": "5.3.3"
}
}
next.config.js
module.exports = {
webpack: (config, options) => {
if (!options.isServer) {
config.target = "electron-renderer";
}
return config;
},
images: {
loader: "akamai",
path: "",
},
};
Ответы (1 шт):
Автор решения: Filipin
→ Ссылка
Помогли изменения в next.config.js
module.exports = {
webpack: (config, options) => {
if (!options.isServer) {
config.target = "electron-renderer";
}
config.plugins.push(
new options.webpack.IgnorePlugin({
resourceRegExp: /(cpu-features|sshcrypto\.node)/u,
})
);
return config;
},
images: {
loader: "akamai",
path: "",
},
};