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

build fails with following error #36

Open
Pranavchiku opened this issue Dec 19, 2024 · 2 comments
Open

build fails with following error #36

Pranavchiku opened this issue Dec 19, 2024 · 2 comments

Comments

@Pranavchiku
Copy link
Member

If you face the following error:

% npx vsce package     
Executing prepublish script 'npm run vscode:prepublish'...

> [email protected] vscode:prepublish
> npm run package


> [email protected] package
> npm run check-types && node esbuild.js --production


> [email protected] check-types
> tsc --noEmit

(node:78135) 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)
/Users/pranavchiku/repos/lfortran-lsp/esbuild.js:1
import * as esbuild from 'esbuild';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1153:20)
    at Module._compile (node:internal/modules/cjs/loader:1205:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

use the following diff:

diff --git a/esbuild.js b/esbuild.js
index 9599ae0..d447f02 100644
--- a/esbuild.js
+++ b/esbuild.js
@@ -1,4 +1,4 @@
-import * as esbuild from 'esbuild';
+const esbuild = require('esbuild');
 
 const watch = process.argv.includes('--watch');
@dylon
Copy link
Collaborator

dylon commented Dec 20, 2024

Please refresh your node dependencies and let me know if the error persists for you:

rm -rf node_modules client/node_modules server/node_modules
npm install

@Pranavchiku
Copy link
Member Author

Pranavchiku commented Dec 20, 2024

% node --version
v20.9.0

No, same error:

% npx vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> [email protected] vscode:prepublish
> npm run package


> [email protected] package
> npm run check-types && node esbuild.js --production


> [email protected] check-types
> tsc --noEmit

(node:25484) 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)
/Users/pranavchiku/repos/lfortran-lsp/esbuild.js:1
import * as esbuild from 'esbuild';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1153:20)
    at Module._compile (node:internal/modules/cjs/loader:1205:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v20.9.0
 ERROR  npm failed with exit code 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants