Bnaya / objectbuffer

JavaScript Object like api, backed by an arraybuffer
MIT License
171 stars 5 forks source link

npm run browser-playground not working: SyntaxError: Cannot use import statement outside a module #172

Closed xuchaoqian closed 3 years ago

xuchaoqian commented 3 years ago

Run "npm install" first, and then run "npm run browser-playground", shows the following error:

> webpack-dev-server --mode=development --config playground/webpack.config.js playground/main.js --open
[webpack-cli] Failed to load '/Users/ab/codebase/objectbuffer/playground/main.js' config
[webpack-cli] /Users/ab/codebase/objectbuffer/playground/main.js:4
import * as objectbufferModules from "../src";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at new Script (node:vm:100:7)
    at NativeCompileCache._moduleCompile (/Users/ab/codebase/objectbuffer/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/Users/ab/codebase/objectbuffer/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (/Users/ab/codebase/objectbuffer/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at WebpackCLI.tryRequireThenImport (/Users/ab/codebase/objectbuffer/node_modules/webpack-cli/lib/webpack-cli.js:245:16)
    at loadConfigByPath (/Users/ab/codebase/objectbuffer/node_modules/webpack-cli/lib/webpack-cli.js:1725:30)
Bnaya commented 3 years ago

I've merged a fix, please pull the recent develop branch and try again. Also, I'm using yarn in this repo. But if NPM works for you, that's also good

xuchaoqian commented 3 years ago

@Bnaya It works perfectly (with NPM) now. Thank you for your quick response.