Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSean Gabriel Villoria
8,515 PointsHeroku Local cannot find module /loader.js
This is my package file.
{
"name": "heroku",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"engine": {
"node": "14.x"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gabbyvilloria/heroku.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/gabbyvilloria/heroku/issues"
},
"homepage": "https://github.com/gabbyvilloria/heroku#readme"
}
I get this error when I run "heroku local" command. What am I doing wrong?
$ heroku local
1:03:20 PM web.1 | internal/modules/cjs/loader.js:1083
1:03:20 PM web.1 | throw err;
1:03:20 PM web.1 | ^
1:03:20 PM web.1 | Error: Cannot find module 'C:\Users\Gabby\source\repos\heroku\app.js;'
1:03:20 PM web.1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
1:03:20 PM web.1 | at Function.Module._load (internal/modules/cjs/loader.js:923:27)
1:03:20 PM web.1 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
1:03:20 PM web.1 | at internal/main/run_main_module.js:17:47 {
1:03:20 PM web.1 | code: 'MODULE_NOT_FOUND',
1:03:20 PM web.1 | requireStack: []
1:03:20 PM web.1 | }
[DONE] Killing all processes with signal SIGINT
1:03:20 PM web.1 Exited with exit code null
1 Answer
Liam Clarke
19,938 PointsHello
The loader cannot find app.js
that you are specifying in your package.json
or Procfile
{
...
"main": "app.js",
...
}
However, it doesn't look like your starting anything as you have no dependencies to express. What is in app.js
if it exists?
Heroku have a good starting tutorial that you may find useful before this video. Heroku Nodejs
Sean Gabriel Villoria
8,515 PointsSean Gabriel Villoria
8,515 PointsHi Liam, thanks for the reply!
Weirdly enough I'm able to build successfully and run on heroku but the local testing fails.
Posting app.js below: