Asking for an advise on how to debug this compiler error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ******@1.1.0 dev: `NODE_ENV=development ts-node ./src/server.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ******@1.1.0 dev 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:
this appears when running ts-node ./src/server.ts
or node build/server.js
tsc
works without errors.
tsconfig.json
:
{
"compilerOptions": {
"lib": [
"es2018",
"dom",
"esnext.asynciterable"
],
"target": "es2018",
"module": "commonjs",
"outDir": "build",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"sourceMap": false,
"rootDirs": ["src", "../shared"]
// "rootDir": "src"
},
"exclude": [
"node_modules",
"**/*.spec.ts",
"**/*.test.ts"
],
"references": [
{ "path": "../shared" }
]
}
I did made some changes in tsconfig which i suppose cause some imports to fail, however the codebase is huge and i really need some pointers to the exact lines in code which caused the error. especially confusing the tsc
runs without errors.
UPDATE:
The issue was with some imports and fixed, However facing similar one again. Know the reason of the current issue - for some reason the imports from shared project (as in here https://www.typescriptlang.org/docs/handbook/project-references.html) are not loaded (despite that they are working in other modules and tsconfig.json is the same with other modules). no particular error, just this npm ERR! code ELIFECYCLE npm ERR! errno 1
.
Question:
However the main question of this topic is not the solution of the particularly this problem, but how to debug this kind of import problems where all available log is basically npm ERR! code ELIFECYCLE npm ERR! errno 1
. I am facing this kind of issues periodically and every time it takes a lot of time to resolve since the only way to debug i know about is to comment chunks of code which might be associated with the possibly failed imports and sometimes this process could take hours.
To Solve npm ERR! code ELIFECYCLE Error You Just need to run this command One by one. First of all Just delete package-lock. json file and then Run this command: npm cache clean –force Then Just run this command: npm install Now, You can Run Your Project with this command: npm start Now, Your Error must be solved.
To solve the Missing script: "start" error, make sure to add a start command to the scripts object in your package. json file and open your shell or IDE in the root directory of your project before running the npm start command.
I solved this problem first delete to package-lock.json
write console
- npm test
(if there isn't any problem in npm installing probably problem is in server)
the problem is solved.. if you want to use your local you can enter
I would start with debugging the compiled script (not minified though) because it removes some intermediate steps between your input and your results. There are multiple methods I tend to debug these issues:
NODE_DEBUG
flags like:
NODE_DEBUG=module node build/server.js
if you suspect the issue is with module loading.node --inspect-brk build/server.js
and starting an inspector to step through it (e.g. in Chrome). This is most helpful if your code actually has managed to load, but can sometimes help with custom loaders.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With