Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

require not working with npm start command

I’m taking my firsts steps with js and node today, so I’ve created the following script:

var fs = require('fs');

function callBack(){}
fs.writeFile('./abc.txt', "My text", callBack);

Very simple script… So when I run it in my terminal with node app.js it works fine, but when I try to run it with npm start it produces the following error:

Line: 1
Error: Expected object
Code: 800A138F

Also, my package.json looks like it:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
    "name": "first_app",
    "version": "1.0.0",
    "private": true,
    "requires": true,

    "scripts": {
        "start": "app.js"
    },
    "dependencies": {
        "fs": "^0.0.1-security"
    }
}

Why am I getting this error and how to solve it?

>Solution :

Try this:

"scripts": {
    "start": "node app.js"
},
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading