Babel dependency not resolved in react app created using "create-react-app" utility - html

I have created a react-app using create-react-app utility but when I import a node module then it gives me error stating :
./node_modules/#nross/react-vega/src/VegaLite.js
Module parse failed: Unexpected token (17:2)
You may need an appropriate loader to handle this file type.
| onParseError,
| children,
| ...otherProps
| }) => {
| const adjustedSpec = { ...spec };
And when I import babel-loader into the file where I am importing the node module then it is giving me the error:-
Failed to compile.
./node_modules/babel-core/lib/helpers/resolve.js
Module not found: Can't resolve 'module' in 'C:\VegaDemo\my-app\node_modules\babel-core\lib\helpers'.

You need to eject in order to customize the boilerplate.
Simply run
npm run eject
Or
yarn run eject
If you use yarn.
Then, install your npm module and run
npm run install
Without eject, the boilerplate is locked up.

Related

i create project in angular 6 using angular cli tool but it gives error import * as fs from 'fs';

i create project in angular 6 using angular cli tool but it gives error when i import * as fs from 'fs'(integrate electron app). The error message Module not found: Error: Cannot resolve module 'fs'
I assume you're using node.
Are you using webpack? If so see
here
The solution is to add
node: {
fs: 'empty'
}
to your webpack config.
If that doesn't work, try changing your import statement to a require:
const fs = require('fs');, as the node documentation recommends.

Node.js Lambda - Using TypeORM with MySql

I'm trying to build some lambda's in node.js and I am using TypeORM with MySql. I have installed all required node modules but when I deploy lambda (via serverless) and test it, I get errors as follows.
Using gulp to build and package .zip.
Log output from test lambda:
START RequestId: 671bed10-81b0-11e7-af34-251688cfdd Version: $LATEST
2017-08-15T11:53:50.594Z 671bed10-81b0-11e7-af34-251688cfdd
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 2): DriverPackageNotInstalledError: Mysql package has
not been found installed. Try to install it: npm install mysql --save
2017-08-15T11:53:50.596Z 671bed10-81b0-11e7-af34-251688cfdd Method:
"GET"
2017-08-15T11:53:50.596Z 671bed10-81b0-11e7-af34-251688cfdd Started
....
2017-08-15T11:53:50.596Z 671bed10-81b0-11e7-af34-251688cfdd
Finished ....
2017-08-15T11:53:50.596Z 671bed10-81b0-11e7-af34-251688cfdd
(node:1) PromiseRejectionHandledWarning: Promise rejection was handled
asynchronously (rejection id: 2)
2017-08-15T11:53:50.597Z 671bed10-81b0-11e7-af34-251688cfddb2
Console error: { DriverPackageNotInstalledError: Mysql package has not
been found installed. Try to install it: npm install mysql --save
at t.Error (native)
at new t (/var/task/index.js:1:48637)
at e.loadDependencies (/var/task/index.js:1:314938)
at new e (/var/task/index.js:1:311241)
at e.createDriver (/var/task/index.js:1:111709)
at e.create (/var/task/index.js:1:104246)
at e.<anonymous> (/var/task/index.js:1:110994)
at r (/var/task/index.js:1:103453)
at Object.next (/var/task/index.js:1:102788)
at /var/task/index.js:1:102697
name: 'DriverPackageNotInstalledError',
message: 'Mysql package has not been found installed. Try to install
it: npm install mysql --save' }
END RequestId: 671bed10-81b0-11e7-af34-251688cfdd
REPORT RequestId: 671bed10-81b0-11e7-af34-251688cfdd Duration: 8.71
ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory
Used: 39 MB
My research has led me to believe that it won't package correctly because its a native module. But i'm not sure. If so is there anyway to get native node modules to work with lambda's??
Any help would be much appreciated, thanks.
EDIT
Folder Structure:
deploy
-- dev
---- serverless.yml
---- PROJECT.zip
-- test
---- serverless.yml
---- PROJECT.zip
-- prod
---- serverless.yml
---- PROJECT.zip
node_modules
-- *
---- *
src
-- api
---- User
------ index.ts
-- data
---- User.ts
-- models
---- User.ts
gulpfile.js
index.ts
package.json
tsconfig.json
tslint.json
Gulp file calls a function from aws-lambda-typescript module that has numerous gulp tasks.
const gulp = require('gulp');
const awsLambdaTypescript = require('aws-lambda-typescript');
awsLambdaTypescript.registerBuildGulpTasks(gulp, __dirname);
Gulp packages .zip in a dist folder and then i copy to deploy>dev and then serverless deploy.
Thanks for your help!
I had a similar issue while testing the lambdas using the Serverless framework. I was using TypeORM and Postgres. So instead of mysql package I used the pg package, but got similar error: pg package has not been found installed.
After investigating for sometime I found that while building the code it was not including the pg package. The pg package was used internally and there was no reference of it in my code. So I thought this could be a reason why it is not being included in the build. To test this I added a reference to the pg package in my code by simply adding a console log.
import * as pg from 'pg';
console.log('This is just to add the reference : ', pg);
And it worked.
I think while packaging, the pg/mysql package is being excluded due to tree shaking or some dead code elimination mechanism. So just try to add a reference of the package in your code and see if it works or not.
import * as mysql from 'mysql';
console.log('This is just to add the reference : ', mysql);
I know it's late to answer but I hope this helps someone in future.
Most likely something is wrong with your packaging process. I'd check the following items:
Check your package.json if mysql is there.
Check the zip file inside your .serverless directory to see if it includes your node_modules.
Download the lambda package that you uploaded and again check if node_modules are there.

Gulp 4 Split Tasks Across Multiple Files Using Gulp-Hub Fails Due to Missing Get Function

Using Gulp 4 and the recipe for splitting my tasks into multiple files using gulp-hub throws this error just from attempting to load the task files. The task file is super simple just wanted to test everything was working.
I found this reference on Undertaker on Github for the get function, but I really don't understand what they are trying to say, and it seems like gulp-hub is supposed to be doing the lifting.
Anyone else run into this and know how to solve it?
Gulp File
'use strict';
var gulp = require('gulp');
var HubRegistry = require('gulp-hub');
// Load some files into the registry
var hub = new HubRegistry(['gulp/tasks/*.js']); // only one file help.js
// Tell gulp to use the tasks just loaded
gulp.registry(hub);
Help Task - /gulp/tasks/help.js
'use strict';
var gulp = require('gulp');
gulp.task('help', []);
Error Thrown
$ gulp help
[01:36:37] Loading gulp\tasks\help.js
D:\projects\app\node_modules\undertaker\lib\helpers\validateRegistry.js:36
throw err;
^
AssertionError: Custom registry must have `get` function
at validateRegistry (D:\projects\app\node_modules\undertaker\lib\helpers\validateRegistry.js:28:5)
at Gulp.registry (D:\projects\app\node_modules\undertaker\lib\registry.js:17:3)
at Object.<anonymous> (D:\projects\app\gulpfile.js:11:6)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
You are probably running gulp-hub#0.8.0 which is the version that is currently published to npm and is designed for gulp 3.x.
For gulp 4.x you need to install gulp-hub from one of the development branches on GitHub. Currently there's 4.0 and registry-init.
The 4.0 branch doesn't work right now because it fails the registry validation of undertaker.
The registry-init branch seems to work however. You can install it like this:
npm uninstall gulp-hub
npm install --save-dev frankwallis/gulp-hub#registry-init
Update on 12.10.2016
I work with yeoman-fountainjs and in their package.json is the following dev-dependency definied, which works like a charm:
"gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb",
"gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4",
I ran into the same error but it was because I failed to expose the tasks correctly to Gulp.
At first I was using CommonJS like this in my help.js file and getting the same error:
exports.help = help;
So I changed it to a Gulp task and it worked:
gulp.task("help", help);

Cabal ExitFailure 1

I'm getting this error when trying to install csv using Cabal (OS X):
Resolving dependencies...
Configuring csv-0.1.2...
Building csv-0.1.2...
Failed to install csv-0.1.2
Build log ( /Users/roshnal/.cabal/logs/csv-0.1.2.log ):
Configuring csv-0.1.2...
Building csv-0.1.2...
Preprocessing library csv-0.1.2...
[1 of 1] Compiling Text.CSV ( Text/CSV.hs, dist/build/Text/CSV.o )
Text/CSV.hs:70:1:
Bad interface file: /Library/Haskell/ghc-7.10.2-x86_64/lib/parsec-3.1.9/Text/ParserCombinators/Parsec.hi
Something is amiss; requested module parsec-3.1.9#parse_8fSmqig53hOL2SEu1k9Tv0:Text.ParserCombinators.Parsec differs from name found in the interface file AwpZ7A1As1bGsDMsWSTZ1J:Text.ParserCombinators.Parsec
cabal: Error: some packages failed to install:
csv-0.1.2 failed during the building phase. The exception was:
ExitFailure 1
I tried updating Cabal, ghc-pkg recache, and as another answer on SO suggested, setting library-profiling to False (in ~/.cabal/config). None of them are working.
Any idea what I can do to install this package? Earlier I have installed other packages using cabal install successfully.
Thanks!
EDIT
As ErirR suggested in his answer, I ran ghc-pkg list and this is the output I got. I don't appear to be having multiple installs of parsec.
/Library/Frameworks/GHC.framework/Versions/7.10.2-x86_64/usr/lib/ghc-7.10.2/package.conf.d
Cabal-1.22.4.0
GLURaw-1.5.0.1
GLUT-2.7.0.1
HTTP-4000.2.20
HUnit-1.2.5.2
ObjectName-1.1.0.0
OpenGL-2.12.0.1
OpenGLRaw-2.5.1.0
QuickCheck-2.8.1
StateVar-1.1.0.0
array-0.5.1.0
async-2.0.2
attoparsec-0.13.0.1
base-4.8.1.0
bin-package-db-0.0.0.0
binary-0.7.5.0
bytestring-0.10.6.0
case-insensitive-1.2.0.4
cgi-3001.2.2.2
containers-0.5.6.2
deepseq-1.4.1.1
directory-1.2.2.0
exceptions-0.8.0.2
fgl-5.5.2.1
filepath-1.4.0.0
ghc-7.10.2
ghc-prim-0.4.0.0
hashable-1.2.3.3
haskeline-0.7.2.1
haskell-src-1.0.2.0
hoopl-3.10.0.2
hpc-0.6.0.2
hscolour-1.23
html-1.0.1.2
integer-gmp-1.0.0.0
mtl-2.2.1
multipart-0.1.2
network-2.6.2.1
network-uri-2.6.0.3
old-locale-1.0.0.7
old-time-1.1.0.3
parallel-3.2.0.6
parsec-3.1.9 // <-- Here's parsec
pretty-1.1.2.0
primitive-0.6
process-1.2.3.0
random-1.1
regex-base-0.93.2
regex-compat-0.95.1
regex-posix-0.95.2
rts-1.0
scientific-0.3.3.8
split-0.2.2
stm-2.4.4
syb-0.5.1
template-haskell-2.10.0.0
terminfo-0.4.0.1
text-1.2.1.3
tf-random-0.5
time-1.5.0.1
transformers-0.4.2.0
transformers-compat-0.4.0.4
unix-2.7.1.0
unordered-containers-0.2.5.1
vector-0.11.0.0
xhtml-3000.2.1
zlib-0.5.4.2
This SO thread might be relevant:
"requested module differs from name found in the interface file"
I would run ghc-pkg list and see if you have multiple installs of the parsec package.

Load new module in Kamailio

I would like to ask, how can I load new module in Kamailio 4.1.2?
Actually, I have an issue, when I tried to compile my kamaiio.cfg
I've got error:
root#kamailio:/usr/local/# kamailio -c kamailio.cfg
loading modules under /usr/local/lib64/kamailio/modules/
0(25392) ERROR: <core> [sr_module.c:587]: load_module(): ERROR: load_module: could not find module <websocket> in </usr/local/lib64/kamailio/modules/>
0(25392) : <core> [cfg.y:3408]: yyerror_at(): parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 323, column 12-25: failed to load module
0(25392) ERROR: <core> [cfg.y:3272]: yyparse(): cfg. parser: failed to find command ws_handle_handshake
0(25392) : <core> [cfg.y:3411]: yyerror_at(): parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 1083, column 27: unknown command, missing loadmodule?
ERROR: bad config file (2 errors)
when I look physically to the /usr/local/lib64/kamailio/modules/ there is some modules, but websocket.so is missing.
So, how can I get and load module in Kamailio?
Thank you for help!
You haven't installed the module websocket. Edit modules.lst file in the source code directory and add websocket to include_modules variable. If you don't have modules.lst, just do:
make cfg
Alternative is to do:
make cfg include_modules="websocket"
By default, the build system for kamailio compiles and install only the modules that have the same dependencies as the core of the application. For websocket you need to install libunistring and openssl (libssl) devel packages.
Steps to load new module to Kamailio server. (Try if above answer is not working for you)
Check the modules is exist in the default module directly /usr/local/lib64/kamailio/modules.
If found, add loadmodule "module_name.so" in load module section in kamailio.cfg file.
If the module is not found in default module directory, you can check for the source code of that module in the default module source code directory /usr/local/src/kamailio-4.4/kamailio/modules.
If source code found, enter to the module directory. Then create modules' shared object file(.so) by following commands.
./configure
make
make test
make install
Then you will get a shared object file(.so). Copy that file into the default module directory. and load this module from the kamailio.cfg file as mentioned in step 1.
If module source code does not exist in the default source code directory, You need to download the source code from the web. And follow step 3 and 4.