Why does vercel not import libraries? - javascript

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

Related

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"
}
}
`

Angular file-saver unknown provider

I installed angular-file-saver with
bower install angular-file-saver
Then I added the dependancy in my bower.json file :
{
"name": "app",
"version": "0.0.0",
"dependencies": {
"angular": "^1.4.0",
"bootstrap": "^3.2.0",
"file-saver.js": "^1.20150507.2"
},
"devDependencies": {
"angular-mocks": "^1.4.0"
},
"appPath": "app",
"moduleName": "app",
"overrides": {
"bootstrap": {
"main": [
"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js"
]
}
}
}
The bower.json from file-saver.js is
{
"name": "file-saver.js",
"main": "FileSaver.js",
"version": "1.20150507.2",
"homepage": "https://github.com/Teleborder/FileSaver.js",
"authors": [
"Eli Grey (http://eligrey.com)"
],
"description": "A saveAs() FileSaver implementation",
"keywords": [
"File",
"FileSaver",
"saveAs"
],
"license": "LICENSE.md",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"demo",
"FileSaver.min.js"
]
}
Then I imported it in my controller :
controller('MainCtrl', ['$http', 'file-saver.js', function ($http, fs) {
But I get the error :
Error: "[$injector:unpr] Unknown provider: file-saver.jsProvider <- file-saver.js <- MainCtrl
https://errors.angularjs.org/1.7.8/$injector/unpr?p0=file-saver.jsProvider%20%3C-%20file-saver.js%20%3C-%20MainCtrl"
I tried other names like file-saver, FileSaver, FileSaver.js but nothing works.
The documentation says that you need to import the ngFileSaver module in your module and then inject FileSaver in your component. Here's the example provided:
angular
.module('fileSaverExample', ['ngFileSaver'])
.controller('ExampleCtrl', ['FileSaver', 'Blob', ExampleCtrl]);
After that, you can invoke FileSaver.saveAs method.

electron-builder - only build for mac but set to build mac and win

This is the first time I am building electronjs app so most probably I don't know what I am doing.
I follow the instruction from the github and this.
This is my package.json:
{
"name": "ExampleApp",
"productName": "ExampleApp",
"version": "1.0.0",
"description": "Fun app.",
"license": "MIT",
"repository": "user/repo",
"author": {
"name": "sooon",
"email": "Example#gmail.com",
"url": "Example.com"
},
"build": {
"appId": "com. Example.ExampleApp",
"mac": {
"target": "dmg",
"icon": "build/icon.png"
},
"win": {
"target": "nsis",
"icon": "build/icon.png"
}
},
"scripts": {
"test": "xo",
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
},
"dependencies": {
"electron-debug": "^1.0.0",
"jquery": "^3.3.1"
},
"devDependencies": {
"devtron": "^1.1.0",
"electron": "^1.8.2",
"electron-builder": "^19.56.0",
"electron-packager": "^8.7.2",
"xo": "^0.18.0"
},
"xo": {
"envs": [
"node",
"browser"
]
}
}
As you can see I have mac and win in the build script. But when I run:
nom run dist
only DMG file (fully functional) is build. There is not trace of any work with win app. What had I miss out in the setting?
I am building this with my MacBook running on 10.12.6. Is it only you can build for your own platform? Can Mac build for Windows?
Update01
I took out:
"build": {
"appId": "com.sooonism.pipidance",
"mac": {
"target": "dmg",
"icon": "build/icon.png"
},
"win": {
"target": "nsis",
"icon": "build/icon.png"
}
},
from the package.json and it still build ok. That means the build script is located somewhere maybe?
electron-builder defaults to building for the current platform. To build both, you need to do something like this in the "script", to build the mac and the window:
"dist-all": "electron-builder -mw"

Uncaught TypeError: Polymer.Base.create is not a function

I have created a web-component with different dependencies, among them is iron-icon component powered by Polymer.
However, when I deploy my component I see the next message in the console:
"Uncaught TypeError: Polymer.Base.create is not a function" in the iron-icon.html file, line 142.
To install the dependencies of the proyect I have used the next bower.json:
{
"name": "facebook-wall",
"version": "1.0.0",
"keywords": [
"polymer",
"web-components",
"facebook",
"wall",
"facebook-wall"
],
"main": "facebook-wall.html",
"dependencies": {
"iron-ajax": "PolymerElements/iron-ajax",
"paper-header-panel": "PolymerElements/paper-header-panel",
"paper-styles": "PolymerElements/paper-styles",
"iron-icon": "PolymerElements/iron-icon",
"iron-icons": "PolymerElements/iron-icons",
"paper-icon-button": "PolymerElements/paper-icon-button",
"paper-material": "PolymerElements/paper-material",
"paper-button": "PolymerElements/paper-button",
"web-component-tester": "Polymer/web-component-tester#~4.2.1",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"paper-behaviors": "PolymerElements/paper-behaviors#~1.0.12"
},
"devDependencies": {
"polymer-test-tools": "Polymer/polymer-test-tools#master",
"mocha": "~1.14.0",
"sinon": "http://sinonjs.org/releases/sinon-1.10.2.js"
},
"resolutions": {
"mocha": "^2.3.0"
},
"authors": [
"Miguel Ortega Moreno <miguel.ortega.moreno5#gmail.com>"
],
"description": "Polymer component which show a facebook wall",
"moduleType": [],
"license": "MIT",
"homepage": "https://github.com/Mortega5/facebook-wall",
"ignore": [
"node_modules",
"bower_components",
"test",
"tests",
"*.*~"
]
}
Do you know what is wrong with it?

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