Engines field is required but was not found in functions\package.json - javascript

I have this error. Please help me.
Engines field is required but was not found in functions\package.json.
To fix this, add the following lines to your package.json:
"engines": {
"node": "8"
}
my package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.4",
"lodash": "^4.17.10"
},
"private": true
}

Need update firebase cli;
npm install -g firebase-tools
Reference:
https://firebase.google.com/docs/cli#macos

You should insert the node engines into your package.json. Try this:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.4",
"lodash": "^4.17.10"
},
"engines": {
"node": ">= 8.0.0"
},
"private": true
}
For more information, checkout the documentation if you're interested.
Edit:
Some commenters mentioned that setting the node version sould be done without the decimals. So try:
"engines": {
"node": ">= 8"
}
also.

=== Deploying to 'datingmuslimanetchat'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
+ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
Error: package.json in functions directory has an engines field which is unsupported. The only valid choices are: {"node": "8"} and {"node": "10"}. Note that Node.js 6 is now deprecated.
PS C:\Users\samir\Desktop\folder>

Related

Node Live-server suddendly stopped working and now is showing weird stuff

I last used it on wednesday last week when I worked and it worked perfectly fine with no problems. Now that I came back today and wanted to start it with live-server it showed symbolds in the console and even waiting for 5 minutes nothing else happaned.
The weird stuff which is showing up
It tried to use powershell instead of the command prompt. At first it told me that scripts are disabled so I searched that, enabled scripts and the exact same thing then happaned as in the command prompt.
I didn't find anything about this weird problem. I even installed the oldest version of it but nothing changed.
For context, this issue doesn't happen on my laptop but it happens on my desktop at home
My desktop and office pc both are a few years old in terms of hardware but couldn't be any more different besides windows 10 pro.
As i posted in the comment, the developer of the color.js & faker.js package has corrupted his packages on purpose: https://www.bleepingcomputer.com/news/security/dev-corrupts-npm-libs-colors-and-faker-breaking-thousands-of-apps/
The live-server depends on the color package: "colors": "latest",
You can see this if you take a look on the package.json
{
"name": "live-server",
"version": "1.2.1",
"description": "simple development http server with live reload capability",
"keywords": [
"front-end",
"development",
"tool",
"server",
"http",
"cli"
],
"author": "Tapio Vierros",
"dependencies": {
"chokidar": "^2.0.4",
"colors": "latest",
"connect": "^3.6.6",
"cors": "latest",
"event-stream": "3.3.4",
"faye-websocket": "0.11.x",
"http-auth": "3.1.x",
"morgan": "^1.9.1",
"object-assign": "latest",
"opn": "latest",
"proxy-middleware": "latest",
"send": "latest",
"serve-index": "^1.9.1"
},
"devDependencies": {
"eslint": "^5.9.0",
"jshint": "^2.9.6",
"mocha": "^5.2.0",
"supertest": "^3.3.0"
},
"scripts": {
"lint": "eslint live-server.js index.js",
"hint": "jshint live-server.js index.js",
"test": "mocha test --exit && npm run lint"
},
"bin": {
"live-server": "./live-server.js"
},
"repository": {
"type": "git",
"url": "https://github.com/tapio/live-server.git"
},
"engines": {
"node": ">=0.10.0"
},
"preferGlobal": true,
"license": "MIT",
"eslintConfig": {
"env": {
"node": true
},
"rules": {
"quotes": 0,
"curly": 0,
"strict": 0,
"no-process-exit": 0,
"eqeqeq": 1,
"no-unused-vars": 1,
"no-shadow": 1
}
}
}
More information about color.js: https://github.com/Marak/colors.js/issues/285
A fix for live-server can be found here: https://github.com/Marak/colors.js/issues/285#issuecomment-1007890688
Just set it to a older version.
The package.json for Live Server has Colors.js set to use the newest possible version available, latest, so I changed it back to the most recent Colors.js version that didn't have the issue, 1.4.0.
Today, Node.js has been released a new security patch. The problem has been solved for me. You can update on https://nodejs.org/en/blog/vulnerability/jan-2022-security-releases/

Jest and Create-react-app: Cannot use import statement outside a module

I have a React Native application where I have some files with some methods that calls certain endpoints. When I try to run Jest is throwing me an error at a local file that is imported.
I have the next package.json:
{
"name": "appName",
"version": "1.0.0",
"description": "some description",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"#babel/core": "^7.14.2",
"#react-native-community/async-storage": "^1.12.1",
"#react-native-community/netinfo": "^6.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3"
},
"jest": {
"automock": false,
"setupFiles": [
"./jest.setup.js"
]
}
}
And the jest.setup.js file is the following:
import mockRNCNetInfo from '#react-native-community/netinfo/jest/netinfo-mock.js'
jest.mock('#react-native-community/netinfo', () => mockRNCNetInfo)
For the moment, this content is commented, otherwise will throw the same error like in the picture.
I tried to test the same stuff in another project where this #react-native-community/netinfo package wasn't saved in devDependencies but in dependencies and it worked but I am not sure if this is the problem. In this specific project I can't let this package as a dependency, it should be in devDependencies.
I found a lot of issues on this but none of them worked on this case, I don't know what to do anymore. Thank you for your time!
I got this error when I was creating tests with Create-react-app Typescript Jest Axios. Perhaps the following entry in package.json might help.
"jest": {
"transform": {
"^.+\\.[t|j]sx?$": "babel-jest"
},
{ "transformIgnorePatterns": [
"node_modules/(?!#shotgunjed)/"
]
},
I found this answer on internet and it worked for me with some small add-ons but I will post it here maybe will help someone in future:
install babel-jest, babel-preset-env, #babel/runtime and react (the last one might be possible to be necessary only if some other package requires it)
create .babelrc file in root directory and add:
{
"env": {
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
}
}
}
Run your code and should be good to go

strapi upgrade from 3.0.x alpha to beta

I have been following this tutorial to play around with strapi
https://strapi.io/blog/building-a-static-website-using-gatsby-and-strapi
But when I installed, I installed alpha instead of beta
I am trying to upgrade to beta so I followed the instructions here
https://strapi.io/documentation/3.0.0-beta.x/migration-guide/migration-guide-alpha.26-to-beta.html
I followed the instructions to change modify package.json then I ran npm i which gave me an error of notarget No matching version found for strapi-hook-knex#3.0.0-beta.x.
then instead of what the documentation mentioned changing all alpha related to beta.x
"strapi": "3.0.0-alpha.26.2" -> "strapi": "3.0.0-beta.x"
I did "strapi": "^3.0.0-beta.17.5"
which makes the command npm i ran successfully so I continued with the instructions. After I am done, I tried running strapi develop I get an error of error Error: Missing extensions folder. Please create one in your app root directory so I added in the folder named extensions manually then try to start up strapi develop but then I get an error of error Error: Cannot find module 'strapi-hook-bookshelf/lib/utils/'
I tried removing node_modules clean npm cache and also the .cache folder within the project but none of those worked though.
Here is a complete modified package.json
{
"name": "cms",
"private": true,
"version": "0.1.0",
"description": "A Strapi application.",
"main": "./server.js",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi",
"lint": "node_modules/.bin/eslint api/**/*.js config/**/*.js plugins/**/*.js"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-react": "^7.7.0"
},
"dependencies": {
"axios": "^0.19.0",
"knex": "latest",
"lodash": "^4.17.5",
"pg": "^7.13.0",
"sqlite3": "latest",
"strapi": "^3.0.0-beta.17.5",
"strapi-admin": "^3.0.0-beta.17.5",
"strapi-email-nodemailer": "^0.2.1",
"strapi-hook-bookshelf": "^3.0.0-beta.17.5",
"strapi-hook-knex": "^3.0.0-beta.17.5",
"strapi-plugin-content-manager": "^3.0.0-beta.17.5",
"strapi-plugin-content-type-builder": "^3.0.0-beta.17.5",
"strapi-plugin-email": "^3.0.0-beta.17.5",
"strapi-plugin-upload": "^3.0.0-beta.17.5",
"strapi-plugin-users-permissions": "^3.0.0-beta.17.5",
"strapi-provider-upload-cloudinary": "^3.0.0-beta.17.5",
"strapi-utils": "^3.0.0-beta.17.5"
},
"author": {
"name": "abc",
"email": "",
"url": ""
},
"maintainers": [
{
"name": "abc",
"email": "",
"url": ""
}
],
"strapi": {
"uuid": "abcf5f65-060b-43f6-b98d-a4687fd81def"
},
"engines": {
"node": "10.x",
"npm": ">= 6.0.0"
},
"license": "MIT"
}
Anyone has idea what I have done wrong?
Thanks in advance for any suggestions + help.
Current versions before upgrading strapi
Strapi - 3.0.0-alpha.26.2 (global)
Node - v10.17.0
npm - 6.11.3
I was experiencing the same issue. I was able to resolve this by emptying my /api folder and the server started working again.

Trouble importing custom library from a repository into an Ember project as a dependency

I am developing a WebGL library that I would like to import into an EmberJS project as a dependency. Unless I'm mistaken, I believe that I can do this via the repository directly without having to make an npm package but I am having trouble getting it to work.
I have made a watered down library and ember project in a couple repos here and here respectively to demonstrate my problem.
If you clone the library and run npm run build it'll make a test bundle which can be called by the test html file packageTest.html. It should print out 'Hello World Test Member is: 5'.
In the Ember project I have a component in which I would like to import the 'HelloWorld' class from the library and call one of its member methods.
import Ember from 'ember';
//import HelloWorld from 'npm-package-test';
export default Ember.Component.extend({
isWide: false,
actions: {
toggleImageSize() {
// var h = new HelloWorld();
// console.log(h.print());
this.toggleProperty('isWide');
}
}
});
When I uncomment the import statement I get the console error
Error: Could not find module 'npm-package-test'
I'm still pretty new to npm packaging and how dependencies work (and know next to nothing about Ember) but from my limited understanding I feel like this method should work the way I currently have it.
For the library, I have the source files being babeled into ES5 in its lib folder. As you can see in the package.json for the library below I have the main set to the index file in the lib folder so that the Ember project can pull the babeled modules.
Library: package.json
{
"name": "npm-package-test",
"version": "1.0.0",
"description": "JibJab Render Library for eCards",
"main": "lib/index.js",
"scripts": {
"prepublishOnly": "npm run build",
"build-test": "browserify test.js > demo/testbundle.js",
"build": "babel ./src -d ./lib && npm run build-test",
"lint": "eslint ./src",
"test": "nyc mocha --require babel-core/register"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nhoughto5/NPM_PackageTest.git"
},
"author": "JibJab",
"license": "ISC",
"bugs": {
"url": "https://github.com/nhoughto5/NPM_PackageTest/issues"
},
"homepage": "https://github.com/nhoughto5/NPM_PackageTeste#readme",
"devDependencies": {
"babel-cli": "6.26.0",
"babel-preset-env": "1.6.1",
"eslint": "4.19.0",
"mocha": "5.0.4",
"nyc": "11.6.0"
},
"nyc": {
"reporter": [
"lcov",
"text"
]
},
"dependencies": {
"domready": "^1.0.8"
}
}
For reference, here is the lib/index.js which should be the entry point of my library:
Library: lib/index.js
'use strict';
module.exports = {
TestClass: require('./TestClass'),
HelloWorld: require('./HelloWorld')
};
In the ember project I have the library repository listed as a dependency:
Ember: package.json
{
"name": "test-ember-app",
"version": "0.0.0",
"description": "Small description for test-ember-app goes here",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-browserify": "1.2.1",
"ember-cli": "2.13.1",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.0.0",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-eslint": "^3.0.0",
"ember-cli-htmlbars": "^1.1.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-mirage": "0.4.3",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-tutorial-style": "2.0.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.13.0",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.13.0",
"ember-welcome-page": "^3.0.0",
"loader.js": "^4.2.3"
},
"engines": {
"node": ">= 4"
},
"private": true,
"dependencies": {
"npm-package-test": "git+https://github.com/nhoughto5/NPM_PackageTest.git"
}
}
When I run npm install in the ember project I can see that the folder structure from the library appears in the node_modules folder. To my limited experience, everything seems correct but for some reason I am still getting this undefined module error.
Is there a step I've missed or some crucial detail I'm missing?
Yes, there’s one step you are still missing. For Ember-CLI to understand that you want to include your npm package in your app’s vendor files, you’ll need to use app.import as outlined here: https://guides.emberjs.com/v3.0.0/addons-and-dependencies/managing-dependencies/
That approach with app.import has existed since Ember-CLI 2.15, but if you are on an older version you’ll need to upgrade first.

How to install npm packages within Google Dialogflow Fullfilment Inline Editor

I would like to install some npm packages into my chatbot but I cant make this working.
package.json file looks as below:
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "~6.0"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^1.5.x",
"firebase-admin": "^4.2.1",
"firebase-functions": "^0.5.7",
"apiai": "^4.0.3"
}
}
In index.js I have:
var jsonQuery = require('json-query');
The logs says:
dialogflowFirebaseFulfillment Function load error: Code in file index.js can't be loaded. Did you list all required modules in the package.json
Any idea?
The error arrived because you didn't include package 'json-query'
run below command after all working fine.
npm install json-query
Answer is simpler than you would think (and #Dhaval mentioned it). You only have to include the name of the npm package in package.json:
{
"some": "crazyPropsFoo",
"engines": {},
"scripts": {},
"dependencies": {
"actions-on-google": "^1.5.x",
"firebase-admin": "~4.1.2",
"firebase-functions": "~0.5",
"npmpackage": "1.8.0", //Here it is
"apiai": "^4.0.3"
}
}
Then require that package in your index.js file:
var PackageObj = require("npmpackage").PackageObject;
var yourVar = new PackageObj();

Categories