I have a notification system. I dont save data directly under user node.
this is my firebase data tree:
+notifall:
+-L-oplpmjınnlın:
+type:"followedyou"
+from:"{followerUid}"
+users:
+{userUid}:
+notif:
+-L-oplpmjınnlın:"true"
When i wanna show notification in recyclerview i do like this:
FirebaseDatabase.getInstance().getReference().child("notifall").child(list.get(position)).addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
holder.uid=dataSnapshot.child("from").getValue().toString();
FirebaseDatabase.getInstance().getReference().child("users").child(holder.uid).child("block").child(FirebaseAuth.getInstance().getUid()).addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot1) {
FirebaseDatabase.getInstance().getReference().child("users").child(dataSnapshot.child("from").getValue().toString()).child("about").addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot1) {
Glide.with(context).load(dataSnapshot1.child("profilephotourl").getValue().toString()).into(holder.profilephoto);
holder.name.setText(dataSnapshot1.child("namesurname").getValue().toString());
if(dataSnapshot.child("type").getValue().toString().equals("followedyou")){
holder.desc.setText(activity.getString(R.string.followedyou));
Drawable drawable = activity.getResources().getDrawable(R.drawable.ic_newfollow);
holder.notiftype.setImageDrawable(drawable);
}
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
});
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
});
}
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
});
Now I wanna implement notifications with Firebase Cloud Messaging. I looked example code in github.
This is my code but it gives me unexpected token error when i try to deploy functions:
exports.sendFollowerNotification = functions.database.ref('/users/{followedUid}/notifs/{notifId}')
.onWrite(async (change, context) => {
const notifId = context.params.notifId;
const followedUid = context.params.followedUid;
var db = admin.database();
db.ref("notifall").child(notifId).once('value',function(snapshot){
if(snapshot.exists()){
const type = snapshot.child("type").val();
if(type==="followedyou"){
const followeruid = snapshot.child("from").val();
db.ref("users").child(followeruid).child("about").once('value',function(snapshot1){
if(snapshot1.exists()){
const name=snapshot1.child("namesurname").val();
const ppurl=snapshot1.child("profilephotourl")
db.ref("users").child(followedUid).child("token").once('value',function(snapshot3){
if(snapshot3.exists()){
const token=snapshot3.val();
var message = {
data: {
title: 'followedyou',
from: followeruid,
name: name,
image: ppurl
},
token: token
};
admin.messaging().send(message)
.then((response) => {
})
.catch((error) => {
});
}
});
}
});
}
}
});
});
How can i fix this?
Worth to mention. Im really begginner in javascript.
Edit: Mistakes
Update: Even when i use official example code from github (https://github.com/firebase/functions-samples/blob/Node-8/fcm-notifications/functions/index.js) İy still give same error.
"Unexpected token =>"
Full error log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/ali/Documents/ShareFunction/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm#6.4.1
3 info using node#v11.1.0
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions#~prelint: functions#
6 info lifecycle functions#~lint: functions#
7 verbose lifecycle functions#~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions#~lint: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ali/Documents/ShareFunction/functions/node_modules/.bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin
9 verbose lifecycle functions#~lint: CWD: /home/ali/Documents/ShareFunction/functions
10 silly lifecycle functions#~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions#~lint: Returned: code: 1 signal: null
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:257:5)
14 verbose pkgid functions#
15 verbose cwd /home/ali/Documents/ShareFunction
16 verbose Linux 4.19.2-1-MANJARO
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "--prefix" "/home/ali/Documents/ShareFunction/functions" "run" "lint"
18 verbose node v11.1.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error functions# lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions# lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Related
While trying to deploy my app on Heroku, I encountered an error as stated in the title: Fatal error: alsa/soundlib.h: No such file or directory
I don't know why this package is troubling me in the first place 'cause i didn't install it and i can't figure out which of my dependencies is depending on it. Anyway, does anyone have idea of how to fix it?
Here is my package.json:
{
"name": "audio-manager",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js",
"dev": "next dev",
"build": "next build",
"next-start": "next start",
"ngrok-start": "ngrok http 3000"
},
"engines": {
"node": "12.x"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#shopify/app-bridge-react": "^1.26.2",
"#shopify/koa-shopify-auth": "^3.1.65",
"#shopify/koa-shopify-graphql-proxy": "^4.0.1",
"#zeit/next-css": "^1.0.1",
"apollo-boost": "^0.4.9",
"crypto": "^1.0.1",
"dotenv": "^8.2.0",
"generate-sound-waveform": "^0.1.11",
"graphql": "^15.3.0",
"js-cookie": "^2.2.1",
"koa": "^2.13.0",
"koa-body": "^4.2.0",
"koa-router": "^9.1.0",
"koa-session": "^6.0.0",
"next": "^9.4.4",
"querystring": "^0.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"safe-compare": "^1.1.4",
"webpack": "^4.44.0"
}
}
I already ran the command: sudo apt-get install libasound2-dev and it installed, but anytime i run npm install it shows this message in the console:
npm install
npm WARN deprecated crypto#1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated mkdirp#0.5.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated coffee-script#1.7.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated mkdirp#0.3.5: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
> speaker#0.3.1 install /home/israel/Documents/sound-wave-image-generator/node_modules/speaker
> node-gyp rebuild
make: Entering directory '/home/israel/Documents/sound-wave-image-generator/node_modules/speaker/build'
CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c: In function ‘initialize_device’:
../deps/mpg123/src/output/alsa.c:78:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
78 | for (i = 0; i < NUM_FORMATS; ++i) {
| ^
../deps/mpg123/src/output/alsa.c: In function ‘get_formats_alsa’:
../deps/mpg123/src/output/alsa.c:201:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
201 | for (i = 0; i < NUM_FORMATS; ++i) {
| ^
AR(target) Release/obj.target/deps/mpg123/liboutput.a
COPY Release/liboutput.a
CXX(target) Release/obj.target/binding/src/binding.o
In file included from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
2294 | , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
| ^
../src/binding.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/binding.cc:30:38: error: no matching function for call to ‘v8::Value::Int32Value()’
30 | ao->channels = info[1]->Int32Value(); /* channels */
| ^
In file included from /home/israel/.cache/node-gyp/12.18.3/include/node/node.h:67,
from ../../nan/nan.h:56,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate: ‘v8::Maybe<int> v8::Value::Int32Value(v8::Local<v8::Context>) const’
2709 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
| ^~~~~~~~~~
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc:31:34: error: no matching function for call to ‘v8::Value::Int32Value()’
31 | ao->rate = info[2]->Int32Value(); /* sample rate */
| ^
In file included from /home/israel/.cache/node-gyp/12.18.3/include/node/node.h:67,
from ../../nan/nan.h:56,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate: ‘v8::Maybe<int> v8::Value::Int32Value(v8::Local<v8::Context>) const’
2709 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
| ^~~~~~~~~~
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc:32:36: error: no matching function for call to ‘v8::Value::Int32Value()’
32 | ao->format = info[3]->Int32Value(); /* MPG123_ENC_* format */
| ^
In file included from /home/israel/.cache/node-gyp/12.18.3/include/node/node.h:67,
from ../../nan/nan.h:56,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate: ‘v8::Maybe<int> v8::Value::Int32Value(v8::Local<v8::Context>) const’
2709 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
| ^~~~~~~~~~
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Write(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/binding.cc:51:33: error: no matching function for call to ‘v8::Value::Int32Value()’
51 | int len = info[2]->Int32Value();
| ^
In file included from /home/israel/.cache/node-gyp/12.18.3/include/node/node.h:67,
from ../../nan/nan.h:56,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate: ‘v8::Maybe<int> v8::Value::Int32Value(v8::Local<v8::Context>) const’
2709 | V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
| ^~~~~~~~~~
/home/israel/.cache/node-gyp/12.18.3/include/node/v8.h:2709:40: note: candidate expects 1 argument, 0 provided
../src/binding.cc:62:78: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
62 | uv_queue_work(uv_default_loop(), &req->req, write_async, (uv_after_work_cb)write_after);
| ^~~~~~~~~~~
../src/binding.cc: In function ‘void {anonymous}::write_after(uv_work_t*)’:
../src/binding.cc:80:31: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
80 | wreq->callback->Call(1, argv);
| ^
In file included from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../../nan/nan.h:1742:3: note: declared here
1742 | Call(int argc, v8::Local<v8::Value> argv[]) const {
| ^~~~
../src/binding.cc: At global scope:
../src/binding.cc:104:17: error: variable or field ‘Initialize’ declared void
104 | void Initialize(Handle<Object> target) {
| ^~~~~~
../src/binding.cc:104:17: error: ‘Handle’ was not declared in this scope
../src/binding.cc:104:30: error: expected primary-expression before ‘>’ token
104 | void Initialize(Handle<Object> target) {
| ^
../src/binding.cc:104:32: error: ‘target’ was not declared in this scope
104 | void Initialize(Handle<Object> target) {
| ^~~~~~
In file included from ../../nan/nan.h:56,
from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../src/binding.cc:155:22: error: ‘Initialize’ was not declared in this scope
155 | NODE_MODULE(binding, Initialize)
| ^~~~~~~~~~
/home/israel/.cache/node-gyp/12.18.3/include/node/node.h:608:36: note: in definition of macro ‘NODE_MODULE_X’
608 | (node::addon_register_func) (regfunc), \
| ^~~~~~~
../src/binding.cc:155:1: note: in expansion of macro ‘NODE_MODULE’
155 | NODE_MODULE(binding, Initialize)
| ^~~~~~~~~~~
In file included from ../src/node_pointer.h:6,
from ../src/binding.cc:5:
../src/binding.cc:93:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Close(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
93 | NAN_METHOD(Close) {
| ^~~~~
../../nan/nan.h:1568:33: note: in definition of macro ‘NAN_METHOD’
1568 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
../src/binding.cc:85:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Flush(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
85 | NAN_METHOD(Flush) {
| ^~~~~
../../nan/nan.h:1568:33: note: in definition of macro ‘NAN_METHOD’
1568 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
../src/binding.cc:47:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Write(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
47 | NAN_METHOD(Write) {
| ^~~~~
../../nan/nan.h:1568:33: note: in definition of macro ‘NAN_METHOD’
1568 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
../src/binding.cc:24:12: warning: ‘Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Open(Nan::NAN_METHOD_ARGS_TYPE)’ defined but not used [-Wunused-function]
24 | NAN_METHOD(Open) {
| ^~~~
../../nan/nan.h:1568:33: note: in definition of macro ‘NAN_METHOD’
1568 | Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
| ^~~~
make: *** [binding.target.mk:122: Release/obj.target/binding/src/binding.o] Error 1
make: Leaving directory '/home/israel/Documents/sound-wave-image-generator/node_modules/speaker/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/israel/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.0-42-generic
gyp ERR! command "/home/israel/.nvm/versions/node/v12.18.3/bin/node" "/home/israel/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/israel/Documents/sound-wave-image-generator/node_modules/speaker
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
I also ran the command: locate asoundlib.h and it gave the following result:
israel#israel-Latitude-E7470:~/Documents/sound-wave-image-generator$ locate asound lib.h
/home/israel/.cache/node-gyp/10.19.0/include/node/zlib.h
/home/israel/.cache/node-gyp/12.18.3/include/node/zlib.h
/home/israel/.nvm/versions/node/v12.18.3/include/node/zlib.h
/home/israel/.nvm/versions/node/v9.0.0/include/node/zlib.h
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/#apollo/client/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/#apollo/react-common/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/#apollo/react-components/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/#apollo/react-hoc/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/#apollo/react-ssr/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/#shopify/polaris-tokens/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/apollo-boost/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/apollo-cache/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/apollo-cache-inmemory/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/apollo-client/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/react-apollo/node_modules/tslib/tslib.html
/home/israel/Documents/Israel-Training-Hamsa/sample-form/node_modules/tslib/tslib.html
/home/israel/Documents/sample-embedded-app/node_modules/tslib/tslib.html
/home/israel/Documents/sound-wave-image-generator/node_modules/tslib/tslib.html
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/ecasound.rb
/snap/core/9436/usr/include/reglib/reglib.h
/snap/core/9665/usr/include/reglib/reglib.h
/snap/gnome-3-34-1804/24/usr/include/stdlib.h
/snap/gnome-3-34-1804/24/usr/include/zlib.h
/snap/gnome-3-34-1804/24/usr/include/X11/XKBlib.h
/snap/gnome-3-34-1804/24/usr/include/X11/Xlib.h
/snap/gnome-3-34-1804/24/usr/include/X11/ICE/ICElib.h
/snap/gnome-3-34-1804/24/usr/include/X11/SM/SMlib.h
/snap/gnome-3-34-1804/24/usr/include/c++/6/stdlib.h
/snap/gnome-3-34-1804/24/usr/include/c++/6/tr1/stdlib.h
/snap/gnome-3-34-1804/24/usr/include/cairo/cairo-xlib.h
/snap/gnome-3-34-1804/24/usr/include/dbus-1.0/dbus/dbus-glib.h
/snap/gnome-3-34-1804/24/usr/include/freetype2/freetype/config/ftstdlib.h
/snap/gnome-3-34-1804/24/usr/include/gdk-pixbuf-2.0/gdk-pixbuf-xlib/gdk-pixbuf-xlib.h
/snap/gnome-3-34-1804/24/usr/include/glib-2.0/glib.h
/snap/gnome-3-34-1804/24/usr/include/glib-2.0/glib/gi18n-lib.h
/snap/gnome-3-34-1804/24/usr/include/harfbuzz/hb-glib.h
/snap/gnome-3-34-1804/24/usr/include/libdbusmenu-glib-0.4/libdbusmenu-glib/dbusmenu-glib.h
/snap/gnome-3-34-1804/24/usr/include/linux/ultrasound.h
/snap/gnome-3-34-1804/24/usr/include/rpcsvc/nislib.h
/snap/gnome-3-34-1804/24/usr/include/sound/asound.h
/snap/gnome-3-34-1804/24/usr/include/sound/asound_fm.h
/snap/gnome-3-34-1804/24/usr/include/x86_64-linux-gnu/bits/stdlib.h
/snap/gnome-3-34-1804/24/usr/lib/x86_64-linux-gnu/libasound.so.2
/snap/gnome-3-34-1804/24/usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
/snap/gnome-3-34-1804/36/usr/include/stdlib.h
/snap/gnome-3-34-1804/36/usr/include/zlib.h
/snap/gnome-3-34-1804/36/usr/include/X11/XKBlib.h
/snap/gnome-3-34-1804/36/usr/include/X11/Xlib.h
/snap/gnome-3-34-1804/36/usr/include/X11/ICE/ICElib.h
/snap/gnome-3-34-1804/36/usr/include/X11/SM/SMlib.h
/snap/gnome-3-34-1804/36/usr/include/c++/6/stdlib.h
/snap/gnome-3-34-1804/36/usr/include/c++/6/tr1/stdlib.h
/snap/gnome-3-34-1804/36/usr/include/cairo/cairo-xlib.h
/snap/gnome-3-34-1804/36/usr/include/dbus-1.0/dbus/dbus-glib.h
/snap/gnome-3-34-1804/36/usr/include/freetype2/freetype/config/ftstdlib.h
/snap/gnome-3-34-1804/36/usr/include/gdk-pixbuf-2.0/gdk-pixbuf-xlib/gdk-pixbuf-xlib.h
/snap/gnome-3-34-1804/36/usr/include/glib-2.0/glib.h
/snap/gnome-3-34-1804/36/usr/include/glib-2.0/glib/gi18n-lib.h
/snap/gnome-3-34-1804/36/usr/include/harfbuzz/hb-glib.h
/snap/gnome-3-34-1804/36/usr/include/libdbusmenu-glib-0.4/libdbusmenu-glib/dbusmenu-glib.h
/snap/gnome-3-34-1804/36/usr/include/linux/ultrasound.h
/snap/gnome-3-34-1804/36/usr/include/rpcsvc/nislib.h
/snap/gnome-3-34-1804/36/usr/include/sound/asound.h
/snap/gnome-3-34-1804/36/usr/include/sound/asound_fm.h
/snap/gnome-3-34-1804/36/usr/include/x86_64-linux-gnu/bits/stdlib.h
/snap/gnome-3-34-1804/36/usr/lib/x86_64-linux-gnu/libasound.so.2
/snap/gnome-3-34-1804/36/usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
/snap/heroku/3962/node_modules/#heroku-cli/color/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-apps/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-apps/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-auth/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-autocomplete/node_modules/#oclif/config/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-buildpacks/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-certs/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-ci/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-config/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-git/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-local/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-pipelines/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-pipelines/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-ps/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-run/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-run/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-status/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-webhooks/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#heroku-cli/plugin-webhooks/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/color/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/command/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/config/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/parser/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-commands/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-commands/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-help/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-legacy/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-not-found/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-plugins/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-plugins/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-update/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-warn-if-update-available/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/#oclif/plugin-which/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/cli-ux/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/edit-string/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/heroku-cli-util/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/rxjs/node_modules/tslib/tslib.html
/snap/heroku/3962/node_modules/tslib/tslib.html
/snap/postman/118/usr/lib/x86_64-linux-gnu/libasound.so.2
/snap/postman/118/usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
/snap/postman/118/usr/share/Postman/resources/app/node_modules/tslib/tslib.html
/snap/postman/118/usr/share/doc/libasound2
/snap/postman/118/usr/share/doc/libasound2-data
/snap/postman/118/usr/share/doc/libasound2/NEWS.Debian.gz
/snap/postman/118/usr/share/doc/libasound2/changelog.Debian.gz
/snap/postman/118/usr/share/doc/libasound2/copyright
/snap/postman/118/usr/share/doc/libasound2/examples
/snap/postman/118/usr/share/doc/libasound2/examples/asoundrc.txt.gz
/snap/postman/118/usr/share/doc/libasound2-data/changelog.Debian.gz
/snap/postman/118/usr/share/doc/libasound2-data/copyright
/snap/postman/119/usr/lib/x86_64-linux-gnu/libasound.so.2
/snap/postman/119/usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
/snap/postman/119/usr/share/Postman/resources/app/node_modules/tslib/tslib.html
/snap/postman/119/usr/share/doc/libasound2
/snap/postman/119/usr/share/doc/libasound2-data
/snap/postman/119/usr/share/doc/libasound2/NEWS.Debian.gz
/snap/postman/119/usr/share/doc/libasound2/changelog.Debian.gz
/snap/postman/119/usr/share/doc/libasound2/copyright
/snap/postman/119/usr/share/doc/libasound2/examples
/snap/postman/119/usr/share/doc/libasound2/examples/asoundrc.txt.gz
/snap/postman/119/usr/share/doc/libasound2-data/changelog.Debian.gz
/snap/postman/119/usr/share/doc/libasound2-data/copyright
/snap/vlc/1700/usr/lib/x86_64-linux-gnu/libasound.so.2
/snap/vlc/1700/usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
/usr/include/asoundlib.h
/usr/include/stdlib.h
/usr/include/alsa/asoundef.h
/usr/include/alsa/asoundlib.h
/usr/include/alsa/sound/asound_fm.h
/usr/include/alsa/sound/uapi/asound_fm.h
/usr/include/c++/9/stdlib.h
/usr/include/c++/9/tr1/stdlib.h
/usr/include/linux/ultrasound.h
/usr/include/reglib/reglib.h
/usr/include/rpcsvc/nislib.h
/usr/include/sound/asound.h
/usr/include/sound/asound_fm.h
/usr/include/sys/asoundlib.h
/usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/lib/x86_64-linux-gnu/libasound.so
/usr/lib/x86_64-linux-gnu/libasound.so.2
/usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_conf_pulse.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_ctl_arcam_av.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_ctl_oss.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_ctl_pulse.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_jack.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_oss.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_pulse.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_upmix.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_usb_stream.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_vdownmix.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_samplerate.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_samplerate_best.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_samplerate_linear.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_samplerate_medium.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_samplerate_order.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_speexrate.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_speexrate_best.so
/usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_rate_speexrate_medium.so
Note: it works well on localhost, this only happen when i try to deploy on Heroku. Any help is appreciated. Thanks in advance.
I'm trying to use Jest to write unit tests for some JavaScript code I have. The problem is that the code file contains functions that aren't defined or imported, so when I try to import the file to test, Jest throws an error about the undefined functions. Is there a way I can get around this? Only import the functions I want to test, for example?
Here's a snippet of the file with the code that I'm trying to test:
// run any data migrations
on("sheet:opened", () => {
sheetMigration();
getAttrs(["btatow_sheet_version"], ({
btatow_sheet_version
}) => {
if (btatow_sheet_version >= 3) {
recalculateSkills();
}
});
});
...
// calculate stat values when XP amount changes
on("change:strength_xp change:body_xp change:reflex_xp change:dexterity_xp change:intelligence_xp change:will_xp change:charisma_xp change:edge_xp", calculateAbilityScore)
const calculateLinkedAttributeValue = attribute => {
if (attribute > 10) {
return Math.floor(attribute / 3);
} else {
if (attribute < 1)
return -4;
else if (attribute < 2)
return -2;
else if (attribute < 4)
return -1;
else if (attribute < 7)
return 0;
else if (attribute < 10)
return 1;
else
return 2;
}
}
...
// exports for testing
module.exports = calculateLinkedAttributeValue
Here's the code in the test file:
const calculateLinkedAttributeValue = require('./sheet-worker')
test('should calculate linked attribute value for attribute value of 0', () => {
expect(calculateLinkedAttributeValue(0)).toBe(-4)
})
I have a package.json file set up, and have brought in Jest as a dependency, like so:
{
"name": "battletech-a-time-of-war",
"version": "1.0.0",
"description": "Character sheet for Roll20 for the A Time of War TTRPG system.",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"jest": "^26.0.1"
},
"type": "module",
"sourceType": "module"
}
Attempting to run the tests via the command line produces the following output:
C:\Stuff\Development\roll20-character-sheets\BattleTech-A-Time-of-War\development>npm run test
> battletech-a-time-of-war#1.0.0 test C:\Stuff\Development\roll20-character-sheets\BattleTech-A-Time-of-War
> jest
FAIL development/sheet-worker.test.js
● Test suite failed to run
ReferenceError: on is not defined
1 | // run any data migrations
> 2 | on("sheet:opened", () => {
| ^
3 | sheetMigration();
4 |
5 | getAttrs(["btatow_sheet_version"], ({
at Object.<anonymous> (development/sheet-worker.js:2:1)
at Object.<anonymous> (development/sheet-worker.test.js:1:39)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.226 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! battletech-a-time-of-war#1.0.0 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the battletech-a-time-of-war#1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<User>\AppData\Roaming\npm-cache\_logs\2020-06-01T09_59_15_484Z-debug.log
EDIT: Add examples and remove link to GitHub source code.
After digging around for a while on the internet and trying different things, I was able to determine the cause of the problem. It's actually nothing to do with Jest, it's the Node require() function. I found out from this StackOverflow comment that the Node require() function basically runs all the code in the file you're importing. Hence it tries to run the undefined functions, and errors.
I am trying to run the following in a node script:
/bin/sh -c '/Users/edwardthompson/IdeaProjects/evidentia4/evidentia4/package/macosx/e/wkhtmltopdf --page-size "letter" --footer-center "[page] of [topage]" --footer-left "Prepared Jul 7, 2019 by Edward A Thompson" --footer-right "Evidentia(c) 2012-2017" --footer-font-size "10" --footer-font-name "Times" --print-media-type /var/folders/45/2rx5vf4j47jf4hx5157q4q800000gn/T/ResearchSummaryReport-201967122421963.html /var/folders/45/2rx5vf4j47jf4hx5157q4q800000gn/T/ResearchSummaryReport-201967122421964.pdf'
Running from the command line, it works fine, but I have to have the quotes around everything being passed to /bin/sh -c
When I do the same thing in a node script:
child = child_process.spawn('/bin/sh -c', ["'" + args.join(' ') + "'"], {stdio: 'inherit'});
I get:
Message:
Uncaught exception: Error: spawn /bin/sh -c ENOENT
Stack:
error properties: Object({ errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn /bin/sh -c', path: '/bin/sh -c', spawnargs: [ ''/Users/edwardthompson/IdeaProjects/evidentia4/evidentia4/package/macosx/e/wkhtmltopdf --page-size "letter" --footer-center "[page] of [topage]" --footer-left "Prepared Jul 7, 2019 by Edward A Thompson" --footer-right "Evidentia(c) 2012-2017" --footer-font-size "10" --footer-font-name "Times" --print-media-type /var/folders/45/2rx5vf4j47jf4hx5157q4q800000gn/T/ResearchSummaryReport-20196712254722.html /var/folders/45/2rx5vf4j47jf4hx5157q4q800000gn/T/ResearchSummaryReport-20196712254722.pdf'' ] })
Error: spawn /bin/sh -c ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:74:11)
Can't figure this one out...
child_process.spawn is looking for a file with a path of "/bin/sh -c", which does not exist. You should pass -c as a parameter instead.
Try this:
child = child_process.spawn('/bin/sh', ["-c","'" + args.join(' ') + "'"], {stdio: 'inherit'});
I am creating my first react-native app. I am attempting to install the react-native command line interface as shown here. I keep getting an error when I type the command to initiate the react-native command line
OS: Windows 10
Node: 10.15.3
npm: 6.4.1
I am not behind a proxy
I have removed the http and https environment variables
Updating node and npm creates a different error as shown here
Here's the error
C:\>npm install -g react-native-cli
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dnort\AppData\Roaming\npm-cache\_logs\2019-04-15T09_52_28_346Z-debug.log
Here's npm get registry
C:\>npm get registry
https://registry.npmjs.org/
Here's npm config get proxy
C:\>npm config get proxy
null
Here's npm config get http-proxy
C:\>npm config get http-proxy
undefined
Here's npm config get https-proxy
C:\>npm config get https-proxy
null
Here's the log file
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'react-native-cli' ]
2 info using npm#6.4.1
3 info using node#v10.15.3
4 verbose npm-session 8e6a6f9ef2e9298d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for react-native-cli#latest Cannot read property 'startsWith' of null
8 timing stage:rollbackFailedOptional Completed in 7ms
9 timing stage:runTopLevelLifecycles Completed in 1811ms
10 verbose stack TypeError: Cannot read property 'startsWith' of null
10 verbose stack at getProxy (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\agent.js:164:25)
10 verbose stack at getAgent (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\agent.js:37:19)
10 verbose stack at remoteFetch (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\index.js:310:17)
10 verbose stack at opts.cacheManager.match.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\index.js:172:14)
10 verbose stack at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
10 verbose stack at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
10 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
10 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
10 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
10 verbose stack at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
10 verbose stack at Promise._resolveCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:432:57)
10 verbose stack at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:524:17)
10 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
10 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
10 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
10 verbose stack at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
11 verbose cwd C:\
12 verbose Windows_NT 10.0.17134
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "react-native-cli"
14 verbose node v10.15.3
15 verbose npm v6.4.1
16 error Cannot read property 'startsWith' of null
17 verbose exit [ 1, true ]
I expect to install the react-native command line to be able to initiate react-native projects.
EDIT
Please see the npm config ls -l input below
C:\Windows\System32>npm config ls -l
; cli configs
long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.4.1 node/v10.15.3 win32 x64"
; userconfig C:\Users\dnort\.npmrc
https-proxy = null
proxy = null
strict-ssl = false
; builtin config undefined
prefix = "C:\\Users\\dnort\\AppData\\Roaming\\npm"
; default values
access = null
allow-same-version = false
also = null
always-auth = false
audit = true
audit-level = "low"
auth-type = "legacy"
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\dnort\\AppData\\Roaming\\npm-cache"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\dnort\\AppData\\Roaming\\npm\\etc\\npmrc"
globalignorefile = "C:\\Users\\dnort\\AppData\\Roaming\\npm\\etc\\npmignore"
group = 0
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\dnort\\.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-options = null
node-version = "10.15.3"
noproxy = null
offline = false
onload-script = null
only = null
optional = true
otp = null
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" (overridden)
preid = ""
production = false
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
; strict-ssl = true (overridden)
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "C:\\Users\\dnort\\AppData\\Local\\Temp"
umask = 0
unicode = false
unsafe-perm = true
update-notifier = true
usage = false
user = 0
; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overridden)
userconfig = "C:\\Users\\dnort\\.npmrc"
version = false
versions = false
viewer = "browser"
There was no proxy set in my configs in npm. I tried npm config get proxy it was null.
Try this link
Solution found
Uninstall current version of node.js and npm from C:\Users{your_username}\AppData\Roaming
Install an older version of node.js. You can do that here. At the time of this post I installed the LTS (Node-10.15.3 & npm-6.4.1).
Remove http & https environment variables. (type in environment variables in search bar which should take your straight to system variables).
Temporarily disable windows defender features.
Restart system
Open administrator node.js command prompt
Enter npm install -g react-native-cli
My result output is now as expected:
C:\Windows\System32>npm install -g react-native-cli
C:\Users\dnort\AppData\Roaming\npm\react-native -> C:\Users\dnort\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli#2.0.1
added 41 packages from 15 contributors in 19.22s
This post is a continuation of my 'How to fix 'npm does not support Node.js v11.14.0 error' on Windows?' here
Note: Most solutions to similar problems have been related to proxy issues, unsupported versions of node.js/npm, environment variables
this may occur cause of coding error, in my case this line caused error
<img class="cat-icon" v-bind:src="require('img/icon/' + icon)" style="width:25px;" />
try to run "npm run watch" to see detailed error
I ran in to similar problem which was caused by wrong ralative path when registring components by require.context
I have tried a variety of commands to delete proxy settings.
I found that the best way to clear out proxy settings is to clear out related entry in .npmrc.
In my case, I simply empty the whole file and restart cmd. And it works.
This helped me:
npm config set proxy http://username:password#host:port
npm config set https-proxy http://username:password#host:port
I have the below es6 class which is in mqttModule.js.
/*jshint esversion: 6*/
import mqtt from 'mqtt';
let client;
class MqttWrapper {
constructor(mqttOptions) {
this.clientId = mqttOptions.clientId;
this.keepAlive = mqttOptions.keepAlive;
this.clean = mqttOptions.clean;
this.reconnectPeriod = mqttOptions.reconnectPeriod;
this.will = mqttOptions.lastWillMessage;
let options = {
clientId: this.clientId,
keepAlive: this.keepAlive,
clean: this.clean,
reconnectPeriod: this.reconnectPeriod,
will: this.will
};
client = mqtt.connect(url, options);
}
}
export {MqttWrapper};
and I am calling it as shown below.
import MqttWrapper from './mqttModule'
let willMessage = {
topic : 'WillMessage',
payload : 'This is the last will message',
qos : 2,
retain : 'true'
}
let mqttOptions = {
clientId : '101',
keepAlive : 10,
clean : 'false',
reconnectPeriod : '1000',
lastWillMessage : willMessage
}
let mqttWrapperObj = new MqttWrapper(mqttOptions);
When I run the gulp command it transpiles fine without any errors. But when I run it, I am getting the error saying type error. Below is the full trace.
G:\Projects\Kube2\edge-node-sdk-js-test\src\app.js:25
var mqttWrapperObj = new _mqttModule2.default(mqttOptions);
^
TypeError: _mqttModule2.default is not a function
at Object.<anonymous> (app.js:19:22)
at Module._compile (module.js:409:26)
at loader (G:\Projects\Kube2\edge-node-sdk-js-test\node_modules\babel-cli\no
de_modules\babel-register\lib\node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (G:\Projects\Kube
2\edge-node-sdk-js-test\node_modules\babel-cli\node_modules\babel-register\lib\n
ode.js:168:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at G:\Projects\Kube2\edge-node-sdk-js-test\node_modules\babel-cli\lib\_babel
-node.js:171:48
at Object.<anonymous> (G:\Projects\Kube2\edge-node-sdk-js-test\node_modules\
babel-cli\lib\_babel-node.js:172:7)
at Module._compile (module.js:409:26)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.4.4
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! edge-node-sdk-js-test#1.0.0 start: `babel-node --presets es2015 ./src/a
pp.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the edge-node-sdk-js-test#1.0.0 start script 'babel-node --pr
esets es2015 ./src/app.js'.
npm ERR! This is most likely a problem with the edge-node-sdk-js-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel-node --presets es2015 ./src/app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs edge-node-sdk-js-test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls edge-node-sdk-js-test
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! G:\Projects\Kube2\edge-node-sdk-js-test\npm-debug.log
Below is my gulp file just incase.
/*jshint esversion: 6 */
const gulp = require('gulp');
const babel = require('gulp-babel');
gulp.task('es6',() => {
return gulp.src('src/app.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('build'));
});
gulp.task('default',['es6'],() => {
gulp.watch('src/app.js',['es6'])
});
And below is the transpiled app.js file that gets created when I run the gulp command.
'use strict';
var _mqttModule = require('./mqttModule');
var _mqttModule2 = _interopRequireDefault(_mqttModule);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var willMessage = {
topic: 'WillMessage',
payload: 'This is the last will message',
qos: 2,
retain: 'true'
}; /*jshint esversion: 6*/
var mqttOptions = {
clientId: '101',
keepAlive: 10,
clean: 'false',
reconnectPeriod: '1000',
lastWillMessage: willMessage
};
var mqttWrapperObj = new _mqttModule2.default(mqttOptions);
I am new to ES6 and babel stuff. Please advice.