-
Notifications
You must be signed in to change notification settings - Fork 417
Description
This is a Bug Report
Description
The command npx sls deploy --conceal
with the following environment variables set failed with the titular error message. After some hacking and searching I think I found the source of the problem, and I'd send in a PR however I'm not yet sure the correct multi-platform solution.
My config:
- Environment variables set via CLI:
NODE_ENV=staging
TS_NODE_PROJECT=webpack/tsconfig-for-webpack-config.json
- Relevant blocks from my serverless.yml:
custom:
webpack:
webpackConfig: webpack/webpack.ts
includeModules: true
package:
individually: true
plugins:
- serverless-dotenv-plugin
- serverless-offline
- serverless-offline-scheduler
- serverless-webpack
And several other things in my config that I'm nearly 100% sure are not relevant to the problem at hand.
Similar or dependent issue(s):
- Google and Firebase - Unexpected end of JSON input #309 - However yarn is not involved at all, just plain NPM.
- Do not swallow errors in case npm ls fails without an empty stdout and use spawn for child processes #373 - This PR changed the affected code to child_process.spawn, which was laudable, but it seems like Node may have changed at some point.
Additional Data
$ npm -v
6.14.4
- Serverless-Webpack Version you're using:
"serverless-webpack": "^5.3.1"
- Webpack version you're using:
"webpack": "^4.29.0"
- Serverless Framework Version you're using:
"serverless": "^1.69.0"
- Operating System: Kubuntu 18.04.3 (equivalent to Ubuntu 18.04.3 LTS)
- Stack Trace (if available):
...
Serverless: Invoke webpack:package
Syntax Error -------------------------------------------
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at /home/ricky/data/dev_slidewave/serverless/node_modules/serverless-webpack/lib/packagers/npm.js:75:19
at tryCatcher (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/method.js:39:29)
at /home/ricky/data/dev_slidewave/serverless/node_modules/serverless-webpack/lib/packagers/npm.js:73:35
at tryCatcher (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/home/ricky/data/dev_slidewave/serverless/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21)
at process.topLevelDomainCallback (domain.js:137:15)
Your Environment Information ---------------------------
Operating System: linux
Node Version: 13.14.0
Framework Version: 1.69.0
Plugin Version: 3.6.9
SDK Version: 2.3.0
Components Version: 2.30.4
As I said I did some digging and it seems that there's a buffering problem with the output of npm ls.
Manual execution of npm ls -prod -json -depth=1 > npmls.json
results in npmls.txt.
So I utilized a concept from SO, though the unbuffer
command isn't preinstalled on my system so I skipped the accepted answer's solution, and the stdbuf
command didn't solve the problem. I modified npm.js::getProdDependencies
as follows:
const command = "script";
const args = [
'-q',
'-c',
`${/^win/.test(process.platform) ? 'npm.cmd' : 'npm'} ls -prod -json -depth=${depth || 1}`,
'/dev/null'
];
Which, while having broad Linux support, won't work on BSD-based platforms or Windows. After making that change that error is resolved and I can proceed to the next problem to solve.
Thus this issue report: I found a solution, but it's not a good solution.