Invalid left-hand side in assignment
See original GitHub issueDescribe the bug
I’m getting an error this error:
Failed to load source map for /node_modules/.vite/@vitejs_plugin-vue.js?v=2c960083
in the chrome console Uncaught SyntaxError: Invalid left-hand side in assignment
The chrome source tab showing error in this part:
var createContext = (ctx) => { ctx = Object.assign({ cwd: process.cwd(), env: "development" }, ctx); if (!ctx.env) { "development" = "development"; // <---- error } return ctx; };
Reproduction
https://stackblitz.com/edit/vitejs-vite-bxj6nd?devtoolsheight=33&file=.env
System Info
OS: macOS 11.1
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 1.36 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.nix-profile/bin/node
npm: 8.1.2 - ~/.nix-profile/bin/npm
Browsers:
Chrome: 97.0.4692.71 (Official Build)
Used Package Manager
npm
Logs
vite-front |
vite-front | > front-template@0.0.3 dev
vite-front | > vite --debug
vite-front |
vite-front | 2022-01-25T17:37:13.696Z vite:config bundled config file loaded in 850.57ms
vite-front | [dotenv][DEBUG] did not match key and value when parsing line 4:
vite-front | 2022-01-25T17:37:13.766Z vite:config using resolved config: {
vite-front | plugins: [
vite-front | 'vite:pre-alias',
vite-front | 'alias',
vite-front | 'vite:modulepreload-polyfill',
vite-front | 'vite:resolve',
vite-front | 'vite:html-inline-script-proxy',
vite-front | 'vite:css',
vite-front | 'vite:esbuild',
vite-front | 'vite:json',
vite-front | 'vite:wasm',
vite-front | 'vite:worker',
vite-front | 'vite:asset',
vite-front | 'vite:vue',
vite-front | 'vite:define',
vite-front | 'vite:css-post',
vite-front | 'vite:client-inject',
vite-front | 'vite:import-analysis'
vite-front | ],
vite-front | define: {
vite-front | 'process.env': {
vite-front | npm_config_user_agent: 'npm/8.3.2 node/v16.3.0 linux x64 workspaces/false',
vite-front | NODE_VERSION: '16.3.0',
vite-front | HOSTNAME: '9cc5f0823d78',
vite-front | YARN_VERSION: '1.22.5',
vite-front | npm_node_execpath: '/usr/local/bin/node',
vite-front | SHLVL: '3',
vite-front | npm_config_noproxy: '',
vite-front | HOME: '/home/node',
vite-front | npm_package_json: '/front/package.json',
vite-front | npm_config_userconfig: '/home/node/.npmrc',
vite-front | npm_config_local_prefix: '/front',
vite-front | COLOR: '0',
vite-front | npm_config_metrics_registry: 'https://registry.npmjs.org/',
vite-front | npm_config_prefix: '/usr/local',
vite-front | npm_config_cache: '/home/node/.npm',
vite-front | npm_config_node_gyp: '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
vite-front | PATH: '/front/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
vite-front | NODE: '/usr/local/bin/node',
vite-front | npm_package_name: 'front-template',
vite-front | npm_lifecycle_script: 'vite --debug',
vite-front | npm_package_version: '0.0.3',
vite-front | npm_lifecycle_event: 'dev',
vite-front | npm_config_globalconfig: '/usr/local/etc/npmrc',
vite-front | npm_config_init_module: '/home/node/.npm-init.js',
vite-front | PWD: '/front',
vite-front | npm_execpath: '/usr/local/lib/node_modules/npm/bin/npm-cli.js',
vite-front | npm_config_global_prefix: '/usr/local',
vite-front | npm_command: 'run-script',
vite-front | NODE_ENV: 'development',
vite-front | INIT_CWD: '/front',
vite-front | EDITOR: 'vi',
vite-front | DEBUG: 'vite:*'
vite-front | },
vite-front | __VUE_OPTIONS_API__: true,
vite-front | __VUE_PROD_DEVTOOLS__: false
vite-front | },
vite-front | build: {
vite-front | target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite-front | polyfillModulePreload: true,
vite-front | outDir: '/front/site',
vite-front | assetsDir: 'assets',
vite-front | assetsInlineLimit: 4096,
vite-front | cssCodeSplit: true,
vite-front | cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite-front | sourcemap: false,
vite-front | rollupOptions: {},
vite-front | minify: 'esbuild',
vite-front | terserOptions: {},
vite-front | write: true,
vite-front | emptyOutDir: null,
vite-front | manifest: false,
vite-front | lib: false,
vite-front | ssr: false,
vite-front | ssrManifest: false,
vite-front | reportCompressedSize: true,
vite-front | chunkSizeWarningLimit: 500,
vite-front | watch: null,
vite-front | commonjsOptions: { include: [Array], extensions: [Array] },
vite-front | dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite-front | },
vite-front | server: {
vite-front | preTransformRequests: true,
vite-front | port: '3001',
vite-front | fs: { strict: true, allow: [Array], deny: [Array] }
vite-front | },
vite-front | ssr: { external: [ 'vue', '@vue/server-renderer' ] },
vite-front | configFile: '/front/vite.config.js',
vite-front | configFileDependencies: [ 'vite.config.js' ],
vite-front | inlineConfig: {
vite-front | root: undefined,
vite-front | base: undefined,
vite-front | mode: undefined,
vite-front | configFile: undefined,
vite-front | logLevel: undefined,
vite-front | clearScreen: undefined,
vite-front | server: {}
vite-front | },
vite-front | root: '/front',
vite-front | base: '/',
vite-front | resolve: { dedupe: undefined, alias: [ [Object], [Object] ] },
vite-front | publicDir: '/front/public',
vite-front | cacheDir: '/front/node_modules/.vite',
vite-front | command: 'serve',
vite-front | mode: 'development',
vite-front | isProduction: false,
vite-front | preview: {
vite-front | port: undefined,
vite-front | strictPort: undefined,
vite-front | host: undefined,
vite-front | https: undefined,
vite-front | open: undefined,
vite-front | proxy: undefined,
vite-front | cors: undefined
vite-front | },
vite-front | env: {
vite-front | VITE_SITE_NAME: 'My Site',
vite-front | VITE_API_URL: 'http://api.site.devi',
vite-front | VITE_MIN_PASSWORD: '9',
vite-front | BASE_URL: '/',
vite-front | MODE: 'development',
vite-front | DEV: true,
vite-front | PROD: false
vite-front | },
vite-front | assetsInclude: [Function: assetsInclude],
vite-front | logger: {
vite-front | hasWarned: false,
vite-front | info: [Function: info],
vite-front | warn: [Function: warn],
vite-front | warnOnce: [Function: warnOnce],
vite-front | error: [Function: error],
vite-front | clearScreen: [Function: clearScreen],
vite-front | hasErrorLogged: [Function: hasErrorLogged]
vite-front | },
vite-front | packageCache: Map(0) {},
vite-front | createResolver: [Function: createResolver],
vite-front | optimizeDeps: {
vite-front | esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite-front | }
vite-front | }
vite-front | 2022-01-25T17:37:16.671Z vite:deps Hash is consistent. Skipping. Use --force to override.
vite-front |
vite-front | vite v2.7.13 dev server running at:
vite-front |
vite-front | > Local: http://localhost:3001/
vite-front | > Network: use `--host` to expose
vite-front |
vite-front | ready in 6088ms.
vite-front |
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Invalid left-hand side in assignment Error in JavaScript
The "Invalid left-hand side in assignment" error occurs when we have a syntax error in our JavaScript code. The most common cause is...
Read more >JavaScript ReferenceError - Invalid assignment left-hand side
This JavaScript exception invalid assignment left-hand side occurs if there is a wrong assignment somewhere in code.
Read more >ReferenceError: Invalid left-hand side in assignment
EsLinter throw Parsing error: Invalid left-hand side in assignment expression for await in second if statement.
Read more >Syntax Error: "Invalid Left-hand Side in assignment."
And here is the problem as you have a value on the left and not a variable which is why you get that:...
Read more >JavaScript ReferenceError – Invalid Assignment Left-Hand Side
The name of this error indicates that this error is caused by a faulty or buggy assignment statement. The “left-hand side error” part...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bluwy Thanks for the kind reminder. I am new to Vite, and It’s all good after putting the code to vite.config.js.
labelling as need production now as issue is many days old without a proper reproduction of original poster