In my background.js file in my chrome extension I cannot "import io from 'socket.io-client'; " since it doesn't start with a /
I find this peculiar since it works in this 5 year old project that I found, however it uses manifest v2. I guess it might have to do with the new version not supporting it yet, but I am here to ask - is there a way for me to do this that I am not aware of?
I've added type module to the service worker in manifets.json, I use the Manifest v3 and I tried to install the socket.io-client with npm so that I could work around the / error and import like: import { io } from "./node_modules/socket.io-client";
However, this just gives me an error that is unknown. How do I do this?
Related
I'm building a Nuxt3 application where I need to import and use a 3rd party node package which internally is using webassembly.
In my case, the package I need is https://github.com/higumachan/lindera-js
Where do I import the package?
In one of my components, right at the beginning of the <script> tag.
And afterwards I'm using it in one of the methods.
(Note: I removed unnecessary code below)
<template>
...
</template>
<script>
import * as lindera from "lindera-js";
...
methods: {
doTranspile() {
const tokenized= lindera.tokenize(this.input);
console.log(tokenized);
},
},
...
</script>
What is the Problem?
After dev server compiles everything and I reload the page in the browser, I get the following error:
[vite] Internal server error: "ESM integration proposal for Wasm" is not supported currently.
Use vite-plugin-wasm or other community plugins to handle this.
Alternatively, you can use .wasm?init or .wasm?url.
See https://vitejs.dev/guide/features.html#webassembly for more details.
The Question
How can I use the package without problems in Nuxt3? Do I have to use vite-plugin-wasm and if so, how and where to use/import it?
Or is there any other way to use a package which is using webassembly?
I found some similar questions on SO, but not sure if they can be used like this in Nuxt3 as I'm fairly new to Nuxt in general.
How to use embedded Webassembly in Vite?
How to include an WASM npm module in svelte with vite?
There are a bunch of similar threads on here however I cannot seem to find anything that works for me. I am building a chrome extension where I'd like to connect to a websocket. I have found a project, https://github.com/matthewlawson/lnm-socket.io, which I try to use as inspiration although I cannot make it work for me.
The server is not in the chrome extension, however I try to access it from my background.js file. That's when I get the Cannot use import statement outside a module error message. Adding "type": "module" to my package.json file doesn't seem to fix it and since it is the background file I do not have it in a script tag to place the "type": "module" in. What can I do?
The following python code is throwing an error on Google App Engine:
import tensorflow_hub as hub
embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder/4")
Error:
RuntimeError: Missing implementation that supports: loader(*('/tmp/tfhub_modules/063d866c06683311b44b4992fd46003be952409c',), **{})
My app.yaml is Standard environment and is using
instance_class: F4_1G
This works on my local box
Seems like similar issue to the one posted here. Would you be able to confirm if this mitigation helped in your case?
The error message 'RuntimeError: Missing implementation ...' comes up when using a directory that exists but does not contain a tfhub_module.pb file with a known module format. In particular, you can get this message by trying to load a hub.Module from a directory that contains something else.
Getting the following error:
"/srv/server.py", line 12, in from .routes.solver import route as solve ImportError: attempted relative import with no known parent package
Deploying the app to AppEngine Standard env, and my project looks like so:
---/
|_app.yaml
|_server.py
|_routes
|_solver.py
In server I do from .routes.solver import route as solve and get the above error in GCP, but not locally.
I tried https://stackoverflow.com/a/16985066/483616 and a few others. Tried with __init__.py at pretty much every level and every location. Then saw that it wasn't needed for python3, so removed. Pretty much unsure what to do now.
Not optimistic that this is the answer but just to throw it into the pot, have you seen Problem with Python relative paths when deploying to Google App Engine Flexible ?
What is the configuration requirements to use import instead of require?
I'm using function runtime v2.
I tried upgrading node to v10.12.0 but still get this error when it hits the imports
Worker was unable to load function store: 'SyntaxError: Unexpected token {'
I have node version set to 10.12.0 in local.settings and in package.json.
my function is setup like this ...
module.exports = async function(context, queueMessage) {
import { cosmos } from "#azure/cosmos";
import { updateChat } from "./channels/chat/newChatMessage";
import { updateAttributeStatus } from
"./channels/attribute/updateAttributeStatus";
import { documentRequest } from "./channels/document/documentRequest";
...
Which version of node is supported by Azure Functions and is import supported? If so, how do I set it up?
Thanks,
Donnie
According to the docs these versions are supported for V2:
Active LTS and Current Node.js versions (8.11.1 and 10.6.0
recommended). Set the version by using the
WEBSITE_NODE_DEFAULT_VERSION app setting.
So the node version has to be set in the Application Settings as explained here.
Regarding the use of import vs require, this is still an experimental feature in Node, therefore I don't think it's possible to use this in Azure Functions yet.
I'd probably go with TypeScript instead and transpile it before uploading (you can find some examples on how to get started with that on GitHub).