I'm trying to implements a little web page which use some NPM import.
This is the package I want to use: https://www.npmjs.com/package/lucid-cardano
I've read https://kotlinlang.org/docs/js-modules.html and Kotlin - How to import node packages? which was very helpful, but I still can't use this package.
For now, this is how I try to use it:
#file:JsModule("lucid-cardano/blockfrost")
#file:JsNonModule
external class Blockfrost
#JsName("new")
external fun new(url: String, projectId: String)
I've also try:
#file:JsModule("lucid-cardano")
#file:JsNonModule
external class Blockfrost
In my App.kt file, I try:
val blockFrost = new("test", "test")
But, it doesn't compile and says Module not found: Error: Can't resolve 'blockfrost'
Could you help me to achieve importing this module or redirect me to an example with the syntax "new" inside the package?
Thanks you!
Related
tried running tests with vitest and it can seem to resolve dependencies from $lib/* and $app/* this is the error, Failed to resolve import "$lib/stores/store" from "src/lib/components/Hello.svelte". Does the file exist? here is the link to the playground https://gitlab.com/paulwvnjohi/hello-vitest
It seems Vitest is NOT automatically picking up your Vite config, since it's "hidden" in svelte.config.js and I'm sure there's tons of magic stuff SvelteKit adds, such as the resolve.alias paths for things like the $lib and $app imports to work.
I don't know if Vitest core would do something automatically in the future, but now there's the vitest-svelte-kit package you can use: https://github.com/nickbreaton/vitest-svelte-kit
Install the package:
npm i -D vitest-svelte-kit
Create a file vitest.config.js and put inside the method that magically extracts the correct vite config for you, according to your settings in svelte.config.js:
// vitest.config.js
import { extractFromSvelteConfig } from "vitest-svelte-kit"
export default extractFromSvelteConfig()
Worked for me!
I'm trying to migrate from vue-cli to Vite using Vue 2.0.
I've some JavaScript-generated files for GRPC communication; alongside each file, there is a declarative file because I'm using Vue with TypeScript. When running Vite, I get this error:
Uncaught SyntaxError: The requested module '/src/proto/admin_config_grpc_web_pb.js' does not provide an export named 'AdminConfigurationServicePromiseClient'
However, I've a corresponding declaration file which contains this line:
export class AdminConfigurationServiceClient {
Anybody has encountered this issue and has a solution?
Thanks
This error is similar to the vite issue https://github.com/vitejs/vite/issues/2117.
Do not re-export typescript type or interface in vite. You can just export it in file A and import it in file B. Don't try to export it in file B again
BTW,
https://github.com/originjs/webpack-to-vite
This is a github project that I found when I searched for error messages when I was converting an old project. It lists some conversion items and error repair methods. It can even convert an old project to a vite project with one click. It’s great, I recommend it!
A workaround can be if you declare a new interface that inherits from the one that you want to re-export.
a.vue
export interface AItem extends ItemModel {}
b.vue
export interface A2Item extends ItemModel {}
I've successfully used the material-components-web library from within my aurelia skeleton-esnext-webpack projects but I am strugling to get them working in a skeleton-esnext project.
The problem seems to be with the fact that the skeleton-esnext project uses jspm with system.js as its module loader.
I have added "#material/textfield": "npm:#material/textfield#^0.3.6" to the jspm dependencies section of my package.json which seems to install the correct #material libraries to my jspm_modules/npm/#material.
Now, when I try to access any class from this library from within any my aurelia view models
import {MDCTextfieldFoundation} from '#material/textfield';
I get the following error in the browser when I run the project:
Error: (SystemJS) Unexpected token import
SyntaxError: Unexpected token import
at eval (<anonymous>)
at Object.eval (http://localhost:9000/jspm_packages/npm/#material/textfield#0.3.6.js:1:123)
at eval (....
Any suggestions to whats most likely causing this issue?
SystemJS is importing the raw source file of the plugin instead of the transpiled one (you can see this if you look into jspm_packages/npm/#material/textfield#0.3.6.js.
You can fix it by changing the location in there to point to the dist directory of the directory textfield#0.3.6. However, it gets overriden all the time on potential updates. And it is not saved in CVS.
Another, more simpler approach, would be to import the correct file in your view model:
import {MDCTextfieldFoundation} from '#material/textfield/dist/mdc.textfield';
I'm playing around with ES6 syntax and would like to build a small module in NPM, which uses another npm module (e.g. push-js) as a dependency. Currently, I'm using rollup to bundle and generate my distribution files.
I'm not sure what's the right way to include a dependency in order to use it in my own module. This is what I tried
import * as Push from 'push.js';
class _MyModule
{
Push.create("Go ahead, click this notification", {
});
}
Rollup triggers the following error on this code:
events.js:160
throw er; // Unhandled 'error' event
^
Error: Unexpected token
Am I doing something fundamentally wrong here?
You are close enough. However, at least in current transpilers (Babel and co.), CommonJS module exports are treated like default exports. Meaning, instead of importing all separate entities (import * as Push), you only have to import the default exports (import Push).
import Push from 'push.js';
class _MyModule
{
constructor() {
Push.create("Go ahead, click this notification", {
});
}
}
How the actual interoperability between CommonJS and ES Modules will be solved, is not yet finalized. See Axel Rauschmayr's blog post on the subject.
When I am trying to import the following module,
>>> from lstm_predictor import lstm_model
The error says no module named lstm_predictor.
How can I solve the problem?
It seems like you are utilizing the lstm_predictor package present in https://github.com/tgjeon/TensorFlow-Tutorials-for-Time-Series.
Since this is not a standard module, make sure you have cloned this project and you have the lstm_predictor.py file in the same folder as your python terminal.