Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: To load an ES module in Azure environment #1308

Open
pronitagrawalvera opened this issue Jun 26, 2024 · 3 comments
Open

Warning: To load an ES module in Azure environment #1308

pronitagrawalvera opened this issue Jun 26, 2024 · 3 comments
Labels
support A request for help setting things up

Comments

@pronitagrawalvera
Copy link

Hi Team,

We are currently facing issues deploying our Chat UI solution in Azure Web App. The error encountered in the console log is as follows:

npm http fetch GET 200 https://registry.npmjs.org/npm 141ms
(node:124) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/site/wwwroot/node_modules/.bin/vite:2
import { performance } from 'node:perf_hooks'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.11.1
npm notice 
npm notice New minor version of npm available! 10.5.0 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice Run npm install -g [email protected] to update!
npm notice 

It appears to be a Node.js issue, and I believe there might be an error in my package.json configuration. I have tried using both Node.js 18 and 20 without success.

Could you please provide me with the correct configuration for package.json to resolve this issue?

@pronitagrawalvera
Copy link
Author

HI @nsarrazin

Do you know the root cause for this issue.

@nsarrazin nsarrazin added the support A request for help setting things up label Jun 26, 2024
@nsarrazin
Copy link
Collaborator

nsarrazin commented Jun 26, 2024

Not sure what would cause this, we use node 20 in our docker image.

If possible try to use the docker image we provide, that should work since we use it in prod for HuggingChat.

@pronitagrawalvera
Copy link
Author

pronitagrawalvera commented Jun 27, 2024

Thanks @nsarrazin but with the docker image you provide, I am getting new error on npm run build command,

npm run build
npm info using [email protected]
npm info using [email protected]

> [email protected] build
> vite build


vite v4.5.3 building SSR bundle for production...
"BaseClient" and "TokenSet" are imported from external module "openid-client" but never used in "src/lib/server/auth.ts".
"Readable" is imported from external module "node:stream" but never used in "src/lib/server/endpoints/cohere/endpointCohere.ts".
✓ 366 modules transformed.

node:internal/event_target:1100
  process.nextTick(() => { throw err; });
                           ^
SyntaxError [Error]: JSON5: invalid character 'u' at 1:1
    at syntaxError (/home/site/wwwroot/node_modules/json5/lib/parse.js:1110:17)
    at invalidChar (/home/site/wwwroot/node_modules/json5/lib/parse.js:1055:12)
    at Object.value (/home/site/wwwroot/node_modules/json5/lib/parse.js:309:15)
    at lex (/home/site/wwwroot/node_modules/json5/lib/parse.js:100:42)
    at Object.parse (/home/site/wwwroot/node_modules/json5/lib/parse.js:25:17)
    at file:///home/site/wwwroot/.svelte-kit/output/server/chunks/auth.js:27:16
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async analyse (file:///home/site/wwwroot/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js:60:16)
    at async MessagePort.<anonymous> (file:///home/site/wwwroot/node_modules/@sveltejs/kit/src/utils/fork.js:22:16)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:326:10)
    at [kOnMessage] (node:internal/worker:337:37)
    at MessagePort.<anonymous> (node:internal/worker:232:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
    at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17) {
  lineNumber: 1,
  columnNumber: 1
}

Node.js v20.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support A request for help setting things up
Projects
None yet
Development

No branches or pull requests

2 participants