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:
{
"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?
CodePudding user response:
Try this:
"scripts": {
"start": "node app.js"
},
CodePudding user response:
in package.json add node before app.js just like this "start": "node app.js"