Closed Batman-Avinash closed 3 years ago
Hello,
Instead of import try using, const packageName = require("package")
or
const name = require("./path to some folder")
The reason why import doesn't work is because we don't have babel configured which compiles es6 and other higher version of javascript to the level where all the browsers can understand it.
and Node doesn't come with babel or webpack configuration
Hope it helps
As stated, I have a PR that involves running Babel first to solve this issue -thanks! https://github.com/bradtraversy/proshop_mern/pull/3
Please update your version of Node to latest. and add "type": "module" in the package.json
System Info:
Error message
SyntaxError: Cannot use import statement outside a module at Module._compile (internal/modules/cjs/loader.js:891:18) at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) at internal/main/run_main_module.js:17:11 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! proshop@1.0.0 start:
node backend/server
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the proshop@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! /home/avinash/.npm/_logs/2020-09-30T22_20_45_659Z-debug.log
Debug