Open bernier opened 2 years ago
@jayair Any idea? I was told:
You need to configure webpack to support node (compiled) addons (ending in '.node').
But I don't have access to the webpack config file when using serverless bundle.
This is the full error when starting serverless. Here's on serverless local, I can still work locally but the CI/CD pipeline stops when reaching this error.
sls offline start
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
serverless-bundle: CommonJS, ES3, or ES5 are not supported
Serverless: Bundling with Webpack...
ERROR in ../../cpu-features/build/Release/cpufeatures.node 1:0
Module parse failed: Unexpected character '�' (1:0)
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)
@ ../../cpu-features/lib/index.js 1:16-60
@ ../../ssh2/lib/protocol/constants.js 7:12-35
@ ../../ssh2/lib/server.js 26:4-38
@ ../../ssh2/lib/index.js 33:10-32
@ ../../ssh2-sftp-client/src/index.js 7:19-34
@ ../../../src/config/sftp.ts 62:41-68
@ ../../../src/handlers/main.ts 77:13-38
ERROR in ../../ssh2/lib/protocol/crypto/build/Release/sshcrypto.node 1:0
Module parse failed: Unexpected character '�' (1:0)
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)
@ ../../ssh2/lib/protocol/crypto.js 30:12-60
@ ../../ssh2/lib/server.js 27:29-60
@ ../../ssh2/lib/index.js 33:10-32
@ ../../ssh2-sftp-client/src/index.js 7:19-34
@ ../../../src/config/sftp.ts 62:41-68
@ ../../../src/handlers/main.ts 77:13-38
webpack compiled with 2 errors
@jayair Got this response from someone related to the ssh2-sftp-client module.
The cpu-features dependency is an optional dependency and is not required for ssh2 to function correctly. Unless you can instruct the serverless environment to respect optional dependencies and not error out when they fail to build
Just found the solution, since I was told these packages were optional, I tried the following and it let me deploy the app:
In serverless.yml
ignorePackages: # Ignore building any of the following packages
- cpu-features
I haven't tried ignoring the crypto package yet since I'm only having this issue on serverless-bundle 5.0.2 but I'm still using 4.4.0 due to https://github.com/AnomalyInnovations/serverless-bundle/issues/259
I can now deploy using version 4.4.0
@jayair Not sure if I should close this ticket. I feel it's a real issue that needs to be fixed in serverless-bundle instead of ignoring it using the config file.
So I now need to upgrade this project to Node > 14.x to be able to use other libraries, but I would need to use serverless-bundle > 4.4.0 Unfortunately, I cannot upgrade due to the following:
ERROR in ../../ssh2/lib/protocol/crypto/build/Release/sshcrypto.node 1:0
Module parse failed: Unexpected character '�' (1:0)
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)
@ ../../ssh2/lib/protocol/crypto.js 30:12-60
@ ../../ssh2/lib/server.js 27:29-60
@ ../../ssh2/lib/index.js 33:10-32
@ ../../ssh2-sftp-client/src/index.js 7:19-34
@ ../../../src/config/sftp.ts 62:41-68
@ ../../../src/handlers/main.ts 77:13-38
This is crazy that nothing has been done since 2021 to handle binary files in this plugin. Please help
Have same issue with bundle 6 version getting same error when I am using sftp client library
Have same issue with bundle 6 version getting same error when I am using sftp client library
Hi please follow the link where i have added the solution. Hope this helps https://github.com/theophilusx/ssh2-sftp-client/issues/477 All you need to do is to add the ssh2 as an external bundle package and as u said I was able to make cpu-features as an optional dependency.
Hi,
I'm using the following SFTP client module https://github.com/theophilusx/ssh2-sftp-client. Everything works great locally but when deploying with Github Actions, I'm getting the following error:
Is there any workaround? I know I could try to use a different SFTP client module that doesn't use the cpu-features module but that one has already been implemented. Thanks!