I'm using nativescript to build android application and using database is Orientdb at homepage http://orientdb.com/ . I'm trying to connect orientdb in Nativescript, use npm Orientjs at homepage https://www.npmjs.com/package/orientjs but have error. The following is the installation process:
step 1: i use command npm install orientjs --save
here is code in package.json
{
"nativescript": {
"id": "org.nativescript.KerryExpressDelivery",
"tns-android": {
"version": "1.7.1"
}
},
"dependencies": {
"orientjs": "^2.1.11",
"tns-core-modules": "1.7.1"
}
}
step 2: i use command var orientDb = require("orientjs"); in file.js but when build app in emulator, get error
com.tns.NativeScriptException: Failed to find module: "net", relative to: /app/tns_modules/
at com.tns.Module.resolvePathHelper(Module.java:220)
at com.tns.Module.resolvePath(Module.java:60)
at com.tns.Platform.callJSMethodNative(Native Method)
at com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)
at com.tns.Platform.callJSMethod(Platform.java:715)
at com.tns.Platform.callJSMethod(Platform.java:694)
at com.tns.Platform.callJSMethod(Platform.java:684)
at com.tns.gen.android.view.View_OnClickListener_ftns_modules_ui_button_button_l19_c42__.onClick(android.view.View$OnClickListener.java)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.
This is probably because OrientDB uses some other node modules that do not work in NativeScript. Although {N} is JS based not all npm modules will work out of the box. NPM Modules that depend browser or node objects will not work.
Related
I have a Vue 2 app that uses Webpack, and I am trying to use in it the node module PSD.js, which in itself utilizes CoffeeScript as part of it's dependencies. When I try to compile i get the error:
Module parse failed: Unexpected character '#' (1:0) You may need an appropriate loader to handle this file type,
referring to the the file ./node_modules/coffee-script/lib/coffee-script/register.js that PSD.js installed as part of it's dependencies when I did npm install psd.
Any ideas on how to make this work?
I understand I need to tell the Vue app how to handle .coffee files with a loader, but I have tried installing coffee-loader, coffee, set the vue.config.js to:
module.exports = {
publicPath: "./",
configureWebpack: {
target: "node-webkit",
node: false,
module: {
rules: [
// ...
{
test: /\.coffee$/,
use: [
{
loader: 'coffee-loader'
}
]
}
]
}
},
lintOnSave: false
};
yet still nothing works, I get the same error. I feel it is because I am not using CoffeeScript directly but rather a node module that I AM using, psd.js, is the one using it. That is why I cannot set lang="coffee" in the script tag attribute of my Vue module (I am using vanilla JS to run everything).
thnx in advance
ADDING MORE INFO:
I use a boilerplate framework to setup my app, and it initialises the vue/webpack app for me indirectly.
To reproduce, and even though this system is for Adobe plugins, you do not need the Adobe host app to see the issue, do:
npm install -g bombino
Then in a folder of your choosing run:
bombino
and fill in these params when asked:
? Name of panel? Hello World
? Use your custom templates or bombino defaults? Bombino
What tooling preset should be used? Vue-CLI
? Which Vue-CLI template should be used? bombino-vue-bare (Absolute minimum)
? Host apps to include: After Effects
? Base CEF Port (between 1024 and 65534) 8666
? Run npm install for you? Yes
then cd into Hello-World and run npm run serve. You should see the app is compiled correctly and is running on some port (8080 or higher if taken).
Now go back to the root folder and install psd.js: npm install psd
then go back into Hello-World and run npm run serve again. This time it will fail to compile with the error I started this question with. Even if you go and install coffee-loader by doing npm install --save coffeescript coffee-loader and change the vue.config.js to be like so:
publicPath: "./",
// Thanks Eric Robinson
configureWebpack: {
target: "node-webkit", // Set the target to node-webkit (https://webpack.js.org/configuration/target/)
node: false, // Don't set certain Node globals/modules to empty objects (https://webpack.js.org/configuration/node/),
module: {
rules: [
// ...
{
test: /\.coffee$/,
use: [
{
loader: 'coffee-loader'
}
]
}
]
}
},
lintOnSave: false
};
or if you do vue use coffee - all of these result in the same error: the compiler/packager doesn't know how to handle the .coffee file (used as a dependency by psd.js).
Thnx again to anyone who has info
I would like to develop an NPM module that the user can import in his project.
The module contain a full administration panel created with Nuxt.
I don't want the user know anything about Nuxt, he just need to run a command like:
myppcommand start
and the application starts a server that is running the administration panel.
So my idea is to develop the NPM module with Nuxt. Generate all the static file inside ./dist folder and then myappcommand start will serve the app from node_modules.
// NPM Package myapp
// nuxt.config.js
export default {
components: [
{
path: '~/components/',
extensions: ['vue']
}
],
buildDir: './.nuxt',
srcDir: './src/',
target: 'static',
ssr: false,
generate: {
dir: './dist/'
}
};
// NPM Package myapp
npx nuxt generate
The command will generate all files in ./dist folder.
// User repo
npm install myapp
This will install myapp inside ./node_modules.
// User repo
cd node_modules/myapp/ && npx nuxt start -c nuxt.config.js
This will start the server and serve the app.
But is this the best way possible? It seems a bit hacky to me, to go inside node_modules, does somebody know a better way?
You could achieve this by declaring that your package has an executable file which starts Nuxt, in the bin property of package.json.
Firstly, create an executable script to start the app:
bin/start.js
#!/usr/bin/env node
// Based on node_modules/.bin/nuxt
global.__NUXT_PATHS__ = (global.__NUXT_PATHS__ || []).concat(__dirname)
require('#nuxt/cli').run(['start'])
.catch((error) => {
require('consola').fatal(error)
process.exit(2)
})
You can verify that this starts the app by running ./bin/start.js (provided you have made the file executable), or node ./bin/start.js.
Then, declare that your package should install this as a script when installed as a dependency:
package.json
{
"bin": {
"myapp": "bin/start.js"
}
}
When your package has been installed with npm install myapp, then node_modules/.bin/myapp will link to node_modules/myapp/bin/start.js and the user will be able to run it with npx myapp.
I'm new to react-native, this community is awesome.
but i'm having an issue with configuring https://github.com/terrylinla/react-native-sketch-canvas with npx create-react-native-app .
all I've done so far is edit the metro.config.js
const extraNodeModules = {
'#terrylinla/react-native-sketch-canvas': './node_modules/#terrylinla\react-native-sketch-canvas/'
}
const resolverMainFields = ['browser','main'];
module.exports = {
resolver: {
extraNodeModules,
resolverMainFields
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
then cmd react-native run-android it bundles correctly but it never loads onto the emulator:
this is what it says in shell:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:8712) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
Jetifier found 987 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Configure project :terrylinla_react-native-sketch-canvas
WARNING: Configuration 'provided' is obsolete and has been replaced with 'compileOnly'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
<============-> 99% EXECUTING [10m 30s]
IDLE
IDLE
:app:installDebug
IDLE
So I just got metro to bundle my js files correctly. I discovered it was something to do with the react-native android gradle it's very confusing. But I just restarted my computer and ran the same commands. That fixed it.
these stackoverflow answers worked before for me to get my build working:
Stuck on info starting JS server
React-native run-android stuck at 99% appDebug
I hope this helps to anyone using create-react-native-app & metro-bundler
This error starting showing up all of a sudden.
Node : v10.16.3
React native : 0.60.5
react-native-cli: 2.0.1
bundling failed: Error: Unable to resolve module stream from /Users/username/React Native/SampleApp/node_modules/browser-stdout/index.js: Module stream does not exist in the Haste module map
It's giving error for this line :
var WritableStream = require('stream').Writable
I tried installing 'stream' via npm
npm install stream
Then other similar errors started showing up.
One option is to use the client package readable-stream. If dependencies are requiring stream, then i would suggest adding the following to your babel config as well.
yarn add readable-stream
yarn add -D babel-plugin-rewrite-require
babel.config.js
module.exports = {
// rest of config
plugins: [
// other plugins
[
'babel-plugin-rewrite-require',
{
aliases: {
stream: 'readable-stream',
},
},
],
],
};
just install stream using npm install stream and run the project again.
I have an electron application using bower to resolve vendor deps and yarn for electron dependencies (node add-ons).
Because bower is deprecated I have migrated to yarn following this guide
how-to-migrate-away-from-bower
that uses bower-away
App launch fine but when I tried to build with electron-builder I got a problem with node module resolution.
$node_modules/.bin/build
• electron-builder version=20.8.1
• writing effective config file=dist/electron-builder-effective-config.yaml
Error: Unresolved node modules: angular, angular-animate, angular-aria, angular-messages, #bower_components/angular-translate, popper.js
at node_modules/electron-builder-lib/src/util/packageDependencies.ts:108:17
you should install of the package like this command
npm i angular --save
Use this answer: https://github.com/electron-userland/electron-builder/issues/2529#issuecomment-465185995
{
...
"dependencies": {
"bootstrap-vue": "^2.0",
"vue": "^2.6",
},
"optionalDependencies": {
"jquery": "1.9.1 - 3",
"popper.js": "^1.14.7"
}
}