I'm learning nodejs through some tutorials and so far it went smooth. Now I got an error and I'm stuck. Can anyone help me with it.
This is my app.js file
var greet5 = require('/greet5');
greet5.greet();
And this is my greet5.js file which is located in same directory as app.js
var greeting = "Hello from Revieling Module pattern";
function greet(){
console.log(greeting);
}
module.exports = {
greet : greet
}
when I run node app.js on terminal this is the error I'm facing.
module.js:328
throw err;
^
Error: Cannot find module '/greet5'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/pankaja/Nodejs/Tests/23-Module Patterns/app.js:19:14)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
Can anyone help me with this. Thanks
The README.md file of the nodejs project, appeared after running nodejs install
, explains you how to run the web app through nodejs.
It says you have to execute npm run dev
on the command line.
Here you are the default README.md:
# Front End Boilerplate
Front-end boilerplate for creating new web projects with Gulp.js and everything you need to get started.
# Getting Started
Required! Gulp installed `npm install -g gulp`
```
$ cd html-boilerplate
$ npm install
$ npm run dev
```
# Build to production
```
$ npm run build
```
Thank you for your suggestions!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.