npm ERR! code ELIFECYCLE internal/modules/cjs/loader.js:583

Hej guys

Just has used hours to fix the problem. I will be thankfull if anyone could help.

I am having trouble with npm start.

I am getting this:

internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module ‘C:\Users\Milaaaaa\Downloads\class05-final-project-first-iteration-master\class05-final-project-first-iteration-master\dist\server\server.js’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! class05-final-project-first-iteration@0.1.0 start: node dist/server/server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the class05-final-project-first-iteration@0.1.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\Milaaaaa\AppData\Roaming\npm-cache_logs\2019-06-26T08_34_25_266Z-debug.log

I have tried to delete node modules and npm install again does not helps :(

When you type npm start it runs the “start” script from the package.json file, or node server.js if one is not specified.

It looks like your package has node dist/server/server.js as the start script and node is not finding that file in that location.

Guessing now… The “dist” in the path suggests that the file is created in some way by building the project, for example by running the TypeScript compiler. It is a common pattern to build files from (say) the src folder and write the production files ready for distribution to the dist folder.

There may be a build script defined. Have a look in the package.json or run npm run to see the scripts.

Thank you for replying.

Well it is truth that I have dist/server/server.js but i dont quite understand if it can not finde the file in that location.

Here is my package.json

"scripts": {
"start": "node dist/server/server.js",
"build-client": "webpack --config webpack.client.config.js --mode production",
"build-server": "webpack --config webpack.server.config.js --mode production",
"build": "npm run build-client && npm run build-server",
"client": "webpack-dev-server --config webpack.client.config.js --mode development --devtool inline-source-map --hot",
"server": "nodemon src/server/index.js --exec babel-node",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "npm run build",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"

},

Have you run the build?

npm run build

There are alternative scripts there for running client and server in developer mode. At least for local testing, you could try:

npm run server

It workes with some warnings when i said npm run dev

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.