Recently I started doing some experiments with , I faced an issue with Netlify Lambda functions and it was showing error " npm ERR! code ELIFECYCLE ".
Following is the error message in the Visual Studio Code (VS Code) after running "npm start" command when running a Netlify Lambda.
PS C:\Users\prowebguru\Documents\node-projects\netlify-test> npm start
netlify-test@1.0.0 start C:\Users\prowebguru\Documents\node-projects\netlify-test
netlify-lambda serve src
netlify-lambda: Starting server
C:\Users\prowebguru\Documents\node-projects\netlify-test\node_modules\toml\lib\parser.js:3833
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
^
[SyntaxError: Expected "#", "\n", "\r" or [ \t] but ";" found.] {
expected: [
{ type: 'literal', value: '#', description: '"#"' },
{ type: 'literal', value: '\n', description: '"\n"' },
{ type: 'literal', value: '\r', description: '"\r"' },
{ type: 'class', value: '[ \t]', description: '[ \t]' }
],
found: ';',
offset: 36,
line: 2,
column: 28
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! netlify-test@1.0.0 start:netlify-lambda serve src
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the netlify-test@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\prowebguru\AppData\Roaming\npm-cache_logs\2020-09-02T16_35_35_126Z-debug.log
I have created a Netlify Lambda using Node, Express, Serverless-http. Created netlify.toml file. I also created 2 commands "start" and "build" in my package.json file.
"scripts": { "start": "netlify-lambda serve src", "build": "netlify-lambda build src" },
Once I run " npm start", I started getting error npm ERR! code ELIFECYCLE
After carefully looking at my code in each and every file and also looking at error message, it was an issue with syntax in my netlify.toml file.
Actually I had put semicolon (";") at the end of the line (JavaScript practice) and I was not able to build Netlify Lambda function.
Here is a sample Netlify.toml file
[build] functions = "functions"
So if you see error in " toml\lib\parser.js " file, then don't forget to check your TOML file for syntax errors.
Did you also face this issue? What was the cause? Comment below and let me know.