I'm trying to do my first skill for alexa and I'm using aws lambda for logic, my problem is that when I run the test it gives me back:
{
"errorMessage": "Cannot find module 'string-similarity'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:474:25)",
"Module.require (module.js:596:17)",
"require (internal/module.js:11:18)",
"Object.<anonymous> (/var/task/index.js:3:24)",
"Module._compile (module.js:652:30)",
"Object.Module._extensions..js (module.js:663:10)",
"Module.load (module.js:565:32)",
"tryModuleLoad (module.js:505:12)",
"Function.Module._load (module.js:497:3)"
]
}
I need string-similarity to compare two strings but I do not understand how to install it in lambda.
this is my package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"alexa",
"skill"
],
"author": "",
"license": "",
"dependencies": {
"ask-sdk": "^2.0.0",
"string-similarity": "^1.2.0",
"i18next": "^10.6.0",
"i18next-sprintf-postprocessor": "^0.2.2"
}
}
and so I call the package in the index.js
'use strict';
const Alexa = require('ask-sdk');
var stringSimilarity = require('string-similarity');
...
how can i solve this error
thanks for your help and sorry for my english but I'm not a native speaker.
You are getting this error because you are using 'string-similarity' but you have not installed it in your project that is why it is giving you "errorMessage": "Cannot find module 'string-similarity'".
You can not add Node Modules directly in Lambda function. If you need to use external modules/libraries you need to have your project in local machine so you can npm install the required modules an then upload the .ZIP file of your project in lambda function see details HERE.
Alternatively you can use ASK CLI to write your code some editor of your choice and deploy the lambda function with a simple command.
Related
I am new to Node.js. I want to create mysql connection and insert data into the database and access it later. I installed, node.js, then using npm installed 'mysql' and 'faker'.
Using node.js I successfully connected to mysql, created database and tables(code in mysql1.js in the folder NODE-JS).
Then I went ahead to create fake data (code in fake_data.js) to insert into the table.
screenshot of vscode
var faker = require("faker");
let first_name = faker.name.firstName();
let last_name = faker.name.lastName();
console.log(Employee: ${prefix} ${first_name} ${last_name} ${suffix});
But this time I got error
code: 'MODULE_NOT_FOUND',
path: 'D:\\DATABASES\\NODE-JS\\node_modules\\faker\\package.json',
requestPath: 'faker'
package.json file contains the following dependencies
{
"dependencies": {
"faker": "^6.6.6",
"mysql": "^2.18.1"
},
"name": "node-js",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
I tried,
var faker = require("./faker");
even then it throws error
please help me to rectify the problem. thanks
The owner of faker deleted it from GitHub at v6.6.6
You can see that here:
https://github.com/marak/Faker.js/
So it is up to the community to complete it
The new repository:
https://github.com/faker-js/faker
This is the official, stable fork of Faker.
Installation
Please replace your faker dependency with #faker-js/faker.
npm install #faker-js/faker --save-dev
Node.js
const { faker } = require('#faker-js/faker');
I’m looking for a way to use a local package (named bs-package) from my Reason React app (named ApplicationA).
bs-package has a single file within src folder called ModuleA.re :
let greet_me = (me) => Js.log("Hello, " ++ me ++ "!");
In ApplicationA I did :
npm install /path/to/bs-package
In node_modules bs-package now appears as symbolic link.
Then added bs-package to bs-dependencies in bsconfig
"bs-dependencies": [
"reason-react",
"bs-package",
],
Then run make world in ApplicationA
bsb -make-world
Now in my Reason React app
ModuleA.greet_me("John");
Gives me
unbound module ModuleA
What am I missing ?
EDIT
Here is the config file of bs-package
It was created with
bsb -init bs-package -theme basic-reson
bsconfig.json
{
"name": "bs-pacakge",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
package.json
{
"name": "bs-pacakge",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "",
"license": "MIT",
"devDependencies": {
"bs-platform": "^5.0.6"
}
}
As suggested, bs-package is namespaced so this should work
BsPackage.ModuleA.greet_me("name")
But the same error appears
unbound module BsPackage
Apparently the bug came from my bs-platform version. I've just switch from version 6.2.1 to version 7.0.1 and everything works fine now (I'm on Windows).
On the Site bower.io,it says "There must be a valid manifest JSON in the current working directory." What does that mean? What is a manifest JSON?
This is referring to the bower.json file. This is a a sample of that:
{
"name": "my-project",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"<name>": "<version>",
"<name>": "<folder>",
"<name>": "<package>"
},
"devDependencies": {
"<test-framework-name>": "<version>"
}
}
I'm not very well versed in nodejs, but I'm trying to install hubot and run it with the hipchat adapter but, I'm getting the following error, package.json below.
I've followed this tutorial, http://theprogrammingbutler.com/blog/archives/2011/10/28/hipchat-hubot-and-me/ and the official one in the hubot-hipchat repo, https://github.com/hipchat/hubot-hipchat - I even tried setting it up on heroku to no avail. I'd prefer to set it up on my ubuntu 12.04 ec2 instance though, but if someone has a surefire way to heroku it's no problem :) Any help is greatly appreciated!
I've set the following environment variables also.
HUBOT_HIPCHAT_JID=<Username>
HUBOT_HIPCHAT_NAME=<Room nickname>
HUBOT_HIPCHAT_PASSWORD=<Password you created for hubots user>
HUBOT_HIPCHAT_TOKEN=<Token from Group Admin and API>
Error:
Error: Argument error
at new JID (/home/ubuntu/falcbot/node_modules/hubot-hipchat/node_modules/node-xmpp/lib/xmpp/jid.js:30:15)
at new Connector (/home/ubuntu/falcbot/node_modules/hubot-hipchat/src/connector.coffee:64:31, <js>:42:13)
at HipChat.run (/home/ubuntu/falcbot/node_modules/hubot-hipchat/src/hipchat.coffee:48:5, <js>:68:19)
at Robot.run (/home/ubuntu/falcbot/node_modules/hubot/src/robot.coffee:389:5, <js>:351:27)
at Object.<anonymous> (/home/ubuntu/falcbot/node_modules/hubot/bin/hubot:124:8, <js>:141:11)
at Object.<anonymous> (/home/ubuntu/falcbot/node_modules/hubot/bin/hubot:5:1, <js>:144:4)
at Module._compile (module.js:456:26)
package.json
{
"name": "hosted-hubot",
"version": "2.6.3",
"author": "GitHub Inc.",
"keywords": [
"github",
"hubot",
"campfire",
"bot"
],
"description": "A simple helpful robot for your Company",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/github/hubot/raw/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "https://github.com/github/hubot.git"
},
"dependencies": {
"hubot": "2.6.3",
"hubot-scripts": "2.5.3",
"hubot-hipchat": "2.5.1-4",
"optparse": "1.0.4"
},
"engines": {
"node": ">= 0.8.x",
"npm": ">= 1.1.x"
}
}
Apparently I forgot to export the variables. I am now not getting any errors when starting hubot with -a hipchat
I have created a npm package, Here is the package.json:
{
"name": "docxgen",
"version": "1.0.5",
"author": "Hans Thunam <hans.thunam#gmail.com>",
"description": "A docX Generator",
"contributors": [
{
"name": "",
"email": ""
}
],
"bin":
{
"docxgen":"./docxgenNode/bin/docxgen"
},
"keywords": [
"DocX",
"templates",
"Generator"
],
"dependencies" : {
"xmldom" : "0.1.x"
},
"devDependencies": {
"jasmine-node":"1.10.x"
},
"license": "MIT",
"engines": {
"node": ">=0.8"
}
}
Then I did sudo npm install -g in the folder of package.json, the installation worked correctly (no error nor warnings).
Howewer, when I then try to execute docxgen file.docx file.json, I get the response: File or command not found. What is strange about this is that it works on Windows 7.
Is there anything different to do for Ubuntu ?
The issue was about the character encoding of the ./docxgenNode/bin/docxgen.
The shell system didn't read the first line correctly.
I started from an existing working binary file that can be found here: https://github.com/LearnBoost/stylus/blob/master/bin/stylus