mike-works / sql-fundamentals

Mike North's SQL Fundamentals and Professional SQL Courses
https://frontendmasters.com/courses/sql-fundamentals/
BSD 3-Clause "New" or "Revised" License
169 stars 108 forks source link

SyntaxError: Cannot use import statement outside a module #327

Closed Wennlys closed 4 years ago

Wennlys commented 4 years ago

Ubuntu 20.04 zsh terminal already tried in node 9, 12 and 13

I already tried to reinstall node dependencies at least 10 times, don't know what to do.

npm run test:watch EX**

Git Branch: Test Filter: EX05 /home/wennlys/www/sql-fundamentals/scripts/test/index.sh: 33: [: =: unexpected operator Applying Test Filter: EX05

/home/wennlys/www/sql-fundamentals/node_modules/pg-packet-stream/src/inbound-parser.test.ts:1 import buffers from './testing/test-buffers' ^^^^^^

SyntaxError: Cannot use import statement outside a module at wrapSafe (internal/modules/cjs/loader.js:1047:16) at Module._compile (internal/modules/cjs/loader.js:1097:27) at Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Object.require.extensions. [as .ts] (/home/wennlys/www/sql-fundamentals/node_modules/ts-node/src/index.ts:392:14) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Module.require (internal/modules/cjs/loader.js:1019:19) at require (internal/modules/cjs/helpers.js:77:18) at /home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/mocha.js:334:36 at Array.forEach () at Mocha.loadFiles (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/mocha.js:331:14) at Mocha.run (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/mocha.js:809:10) at loadAndRun (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/cli/watch-run.js:46:22) at module.exports (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/cli/watch-run.js:61:3) at exports.runMocha (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/cli/run-helpers.js:140:5) at Object.exports.handler (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/cli/run.js:292:3) at Object.runCommand (/home/wennlys/www/sql-fundamentals/node_modules/mocha/node_modules/yargs/lib/command.js:242:26) at Object.parseArgs [as _parseArgs] (/home/wennlys/www/sql-fundamentals/node_modules/mocha/node_modules/yargs/yargs.js:1096:28) at Object.parse (/home/wennlys/www/sql-fundamentals/node_modules/mocha/node_modules/yargs/yargs.js:575:25) at Object.exports.main (/home/wennlys/www/sql-fundamentals/node_modules/mocha/lib/cli/cli.js:68:6) at Object. (/home/wennlys/www/sql-fundamentals/node_modules/mocha/bin/mocha:162:29) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47`

npm run start

info: Database Type: SQLite (node:130803) UnhandledPromiseRejectionWarning: TypeError: express is not a function at Object. (/home/wennlys/www/sql-fundamentals/dist/express-server.js:93:21) at Generator.next () at /home/wennlys/www/sql-fundamentals/dist/express-server.js:7:71 at new Promise () at __awaiter (/home/wennlys/www/sql-fundamentals/dist/express-server.js:3:12) at Object.startExpressServer (/home/wennlys/www/sql-fundamentals/dist/express-server.js:92:12) at /home/wennlys/www/sql-fundamentals/dist/index.js:14:54 at Generator.next () at /home/wennlys/www/sql-fundamentals/dist/index.js:7:71 at new Promise () (node:130803) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:130803) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

jaeming commented 3 years ago

I get the exact same mocha error: SyntaxError: Cannot use import statement outside a module

supermikol commented 3 years ago

I'm getting this when trying to run just the first test after getting the db up and running: DB_TYPE=pg npm run test --- EX00

@Wennlys Did you ever figure out the fix?