npm gulp 800a138f javascript error - javascript

When i put 'gulp hello' in cmd i got this error 800a138f javascript object expected error
This is my package.json file
`{
"name": "goes",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node gulp.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1"
}
}`
This is gulp.js
`var gulp = require('gulp');
gulp.task('hello', function() {
console.log('Hello Zell');
});`

Related

Why does vercel not import libraries?

I tried to create a site in Vercel for my project (link), but for some reason it returned the following error:
Error: Runtime exited with error: exit status 1 Runtime.ExitError
ERROR Cannot find module 'dotenv' Require stack: -/var/task/index.js
ERROR Did you forget to add it to "dependencies" in package.json?
I tried to delete the first line of code from index.js, which requires the dotenv library, since I don't really need it in vercel, but it gives an error when importing express, so I want to know how to solve this problem.
Below is the code of package.json and vercel.json (for some reason I believe the error is in one of these files)
Package.json:
{
"name": "url_saver",
"version": "1.0.0",
"description": "A FCC project",
"main": "index.js",
"engines": {
"node": "14.x"
},
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "~4.18.1",
"mongoose": "~6.6.2",
"dotenv": "~16.0.3",
"dns": "~0.2.2",
"url": "~0.11.0",
"open": "~8.4.0"
},
"keywords": [
"node",
"express",
"freecodecamp",
"mongoose"
],
"license": "MIT",
"author": "Samuel Schlemper"
}
Vercel.json:
{
"version": 2,
"builds": [
{
"src": "./index.js",
"use": "#vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/"
}
]
}
Link to full repository on github: https://github.com/Samuel-Schlemper-Schlemuel/Save_URL

Why isn't electron builder returning a .pkg file?

so I'll keep it short. I've been following this tutorial: https://www.techandstartup.org/tutorials/release-electron-app-on-mac-app-store
However as you'll see we need a pkg file to be uploaded to Transporter for App Store Connect. But when I run 'electron-builder' command I only get an 'Application' .I don't get any .dmg files or .pkg file. This is how my .plis looks like `
{
"name": "APPP",
"productName": "APPP",
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron .",
"dist": "electron-builder --mac"
},
"keywords": [],
"author": {
"name": "ME",
"email": "ME#gmail.com"
},
"license": "MIT",
"devDependencies": {
"electron": "^17.1.2",
"electron-builder": "^22.14.13",
"electron-packager": "^15.5.1"
},
"build": {
"appId": "com.APP",
"productName": "Frost",
"buildVersion": "1.0.0",
"copyright": "Copyright © 2022 Developer or Company Name",
"mac": {
"category": "public.app-category.Productivity",
"icon": "/Users/alex/frost/src/icon.icns",
"target": "dmg",
"hardenedRuntime": false,
"entitlements": "/Users/alex/frost/entitlements.mas.plist",
"entitlementsInherit": "/Users/alex/frost/entitlements.mas.inherit.plist",
"provisioningProfile": "/Users/alex/frost/AppleDevelopment.provisionprofile",
"type": "development"
}
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
}
}
`

npm start not picking up updated package.json

I am writing a node app from scratch, with the following package.json, which is pretty boiler-plate.
{
"name": "myfirstnodeproject",
"version": "1.0.1",
"description": "Learning node",
"main": "index.js",
"start": "node server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"dependencies": {
"request": "^2.88.2"
}
}
I created server.js to look like this:
var http = require("http");
http.createServer((inRequest, inResponse) => {
inResponse.end("Your IP Address is " + inRequest.connection.remoteAddress);
}).listen(9000);
When I started the app using npm start, it worked fine.
Then, I created a new file called server_time.js:
require("http").createServer((inRequest, inResponse) => {
const requestModule = require("request");
requestModule(
"http://worldtimeapi.org/api/timezone/America/New_York",
function (inErr, inResp, inBody) {
inResponse.end(
`Hello from my first Node Web server: ${inBody}`
);
}
);
}).listen(9000);
I changed the following line in my package.json:
"start": "node server_time.js",
However, Node still seems to pick up server.js instead. I tried npm cache verify, npm cache clear --force, rm -rf node_modules, rm package-lock.json, and npm install again, but the problem didn't seem to go away. I even removed package.json and redefined it, but the value of start when I call npm start is still stale.
Here's an output from my shell:
GsMacbookPro:MyFirstNodeProject g$ cat package.json
{
"name": "myfirstnodeproject",
"version": "1.0.1",
"description": "Learning node",
"main": "index.js",
"start": "node server_time.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "G",
"license": "ISC",
"dependencies": {
"request": "^2.88.2"
}
}
GsMacbookPro:MyFirstNodeProject g$ ls
node_modules package-lock.json package.json server.js server_time.js
GsMacbookPro:MyFirstNodeProject g$ npm start
> myfirstnodeproject#1.0.1 start /Users/g/Repos/MyFirstNodeProject
> node server.js
Before someone asks, node version is v10.16.3, and npm version is 6.9.0.
The reason why npm start currently works for you is because npm will default some script values based on package contents.
If there is a server.js file in the root of your package, then npm will default the start command to node server.js.
See here:
npm.js - default values
So your start field inside package.json wasn't actually doing anything because it was not under scripts, which is where it should belong.
The correct approach is to update your package.json so that it looks like the following:
{
"name": "myfirstnodeproject",
"version": "1.0.1",
"description": "Learning node",
"main": "index.js",
"scripts": {
"start": "node server_time.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "G",
"license": "ISC",
"dependencies": {
"request": "^2.88.2"
}
}
Try:
{
"name": "myfirstnodeproject",
"version": "1.0.1",
"description": "Learning node",
"main": "server_time.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server_time.js"
},
"license": "ISC",
"dependencies": {
"request": "^2.88.2"
}
}
and then npm run start.

'console' is 'undefined in the shell by using webpack with node.js

I have a file my-script.js that only returns this:
console.log('Hi I'm working')
When I type in shell only
node my-script.js
This works successfully.
But I'd like it to work too when I typed in just this:
npm start
How to make it work?
Because it is generating an error message:
Line: 1 Error: console is undefined Code: 800A1391 Source: Microsoft
JScript runtime error
I have a package.json file that points to this file to be the start but this is not resolving.
Here is my package.json file:
{
"name": "my-app",
"version": "1.0.0",
"main": "my-script.js",
"scripts": {
"start": "my-script.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"webpack-dev-server": "^3.9.0"
},
"devDependencies": {
"webpack": "^4.41.2"
},
"description": ""
}
Use node in start script
{
"name": "my-app",
"version": "1.0.0",
"main": "my-script.js",
"scripts": {
"start": "node my-script.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"webpack-dev-server": "^3.9.0"
},
"devDependencies": {
"webpack": "^4.41.2"
},
"description": ""
}

request.ref is not a function

I ran the node code on this site https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html by using:
node app
I get the following error:
TypeError: request.ref is not a function.
which corresponds to the following line:
sendNotificationToUser("username","new msg",function() {request.ref().remove();} );
This is my package.json file:
{
"name": "myApp",
"version": "1.0.1",
"description": "listen for addition of msgs",
"main": "app.js",
"scripts": {
"start": "node app.js",
"monitor": "nodemon app.js",
"deploy": "gcloud app deploy"
},
"author": "my name",
"engines": {
"node": "~4.2"
},
"license": "ISC",
"dependencies": {
"firebase": "^3.2.1",
"request": "^2.74.0"
}
}
There are indeed some typos in the code. The actual version I run with uses this to remove the messages that have been sent:
requestSnapshot.ref.remove();
The entire listenForNotificationRequests method (in case I made any other edit mistakes while porting to the blog):
function listenForNotificationRequests() {
var requests = ref.child('notificationRequests');
requests.on('child_added', function(requestSnapshot) {
var request = requestSnapshot.val();
sendNotificationToUser(
request.username,
request.message,
function() {
requestSnapshot.ref.remove();
}
);
}, function(error) {
console.error(error);
});
};

Categories

Resources