How to use ssr supported packages in vue with vue-server-renderer? - vue.js

I tried to use vue2-google-maps and it worked well.
Suddenly my computer had stopped working and then I restarted my computer.
Then, strangely, 500-error comes out.
I reverted all codes associated with vue2-google-maps then my project works well.
Even though when I import vue2-google-maps then It occurs 500-error. :(
App.js
import * as VueGoogleMaps from 'vue2-google-maps';
It was working well but now cause of the unknown reason it has been broken...
Here is my console shows error.
webpack built 5410edae88d11b814c0b in 2690ms
error during render : /search
/media/bossminion/Work/WeMeet/frontend/node_modules/vue2-google-maps/dist/components/infoWindow.vue:3
<template>
^
SyntaxError: Unexpected token <
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/media/bossminion/Work/WeMeet/frontend/node_modules/vue2-google-maps/dist/main.js:42:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at r (/media/bossminion/Work/WeMeet/frontend/node_modules/vue-server-renderer/build.dev.js:9295:16)
at Object.<anonymous> (webpack:/external "vue2-google-maps":1:0)
at __webpack_require__ (webpack:/webpack/bootstrap a442baf8af813fadc2a4:25:0)
error during render : /favicon.ico
/media/bossminion/Work/WeMeet/frontend/node_modules/vue2-google-maps/dist/components/infoWindow.vue:3
<template>
^
SyntaxError: Unexpected token <
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/media/bossminion/Work/WeMeet/frontend/node_modules/vue2-google-maps/dist/main.js:42:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at r (/media/bossminion/Work/WeMeet/frontend/node_modules/vue-server-renderer/build.dev.js:9295:16)
at Object.<anonymous> (webpack:/external "vue2-google-maps":1:0)
at __webpack_require__ (webpack:/webpack/bootstrap a442baf8af813fadc2a4:25:0)
Is it possible that project that worked well could cause 500-error for no reason?
Environment: Ubuntu 18.04, npm v6.9.0, node v12.6.0

I have found how to handle ssr.
App.js
if (process.browser) {
const VueGoogleMaps = require('vue2-google-maps');
Vue.use(VueGoogleMaps, {
load: {
key: 'myKey',
libraries: 'places',
},
});
}
Instead of using import, I used require when it is client rendering.
I will be happy if it helped you. :D

Related

Unable to create vue js project with "vue create projectName" command

I try to runvue create my-project in my terminal, I've got this render :
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'rxjs'
Require stack:
- /usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/ui/prompt.js
- /usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/inquirer.js
- /usr/local/lib/node_modules/#vue/cli/lib/create.js
- /usr/local/lib/node_modules/#vue/cli/bin/vue.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/ui/prompt.js:7:36)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159: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) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/ui/prompt.js',
'/usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/inquirer.js',
'/usr/local/lib/node_modules/#vue/cli/lib/create.js',
'/usr/local/lib/node_modules/#vue/cli/bin/vue.js'
]
}
Whereas before, the command worked well!
Could someone help me to solve this problem?
Thanks in advance !

How to solve the problem with installing npm install "Cannot find module #npmcli/git"?

How to fix it?
npm install swiper
Error: Cannot find module '#npmcli/git'
Require stack:
C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\git.js
C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\fetcher.js
C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\index.js
C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\lib\utils\update-notifier.js
C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\lib\cli.js
C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\Oleg\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\git.js:6:13).js:6:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
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)

Why npm can't find module '../../package.json' even if it already exists

The problem: when I start using npm commands I see the same error:
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module '../../package.json'
Require stack:
- C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js
- C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155: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) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Demian\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\utils\\unsupported.js',
'C:\\Users\\Demian\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js',
'C:\\Users\\Demian\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'
]
}
The same problem with npm i, -v, init and etc. The same error is when I start it from C:/user or in a project with package.json where all works before. node works correctly. What should I do?

Updating vue library to vue 3 using vue-next

I'm trying to upgrade a library I made to vue3, using the vue cli with vue add vue-next, but I get the following error
I removed nodemodule and installed it again, and I removed the vue-template-compiler, because it doesn't work with vue3, but it still gives me this error.
Thank you for the help in advance.
Update: I removed vue-template-compiler and now it gives me this error:
[!] Error: Cannot find module 'vue-template-compiler'
Require stack:
- C:\projects\UTT-Message-System\module\node_modules\#vue\component-compiler\dist\compiler.js
- C:\projects\UTT-Message-System\module\node_modules\#vue\component-compiler\dist\index.js
- C:\projects\UTT-Message-System\module\node_modules\rollup-plugin-vue\dist\rollup-plugin-vue.js
- C:\projects\UTT-Message-System\module\build\rollup.config.js
- C:\projects\UTT-Message-System\module\node_modules\rollup\dist\shared\loadConfigFile.js
- C:\projects\UTT-Message-System\module\node_modules\rollup\dist\bin\rollup
Error: Cannot find module 'vue-template-compiler'
Require stack:
- C:\projects\UTT-Message-System\module\node_modules\#vue\component-compiler\dist\compiler.js
- C:\projects\UTT-Message-System\module\node_modules\#vue\component-compiler\dist\index.js
- C:\projects\UTT-Message-System\module\node_modules\rollup-plugin-vue\dist\rollup-plugin-vue.js
- C:\projects\UTT-Message-System\module\build\rollup.config.js
- C:\projects\UTT-Message-System\module\node_modules\rollup\dist\shared\loadConfigFile.js
- C:\projects\UTT-Message-System\module\node_modules\rollup\dist\bin\rollup
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\projects\UTT-Message-System\module\node_modules\#vue\component-compiler\dist\compiler.js:26:26)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Object.require.extensions.<computed> [as .js] (C:\projects\UTT-Message-System\module\node_modules\rollup\dist\shared\loadConfigFile.js:516:13)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\projects\UTT-Message-System\module\node_modules\#vue\component-compiler\dist\index.js:6:20)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Object.require.extensions.<computed> [as .js] (C:\projects\UTT-Message-System\module\node_modules\rollup\dist\shared\loadConfigFile.js:516:13)

jest-haste-map: watch error complaining that it can't find a file in the jest-haste-map node_modules folder

I just upgraded to RN 0.56.0 and am using jest version: 22.4.3 (updating the jest version doesn't help)
When I try to run my test suite, I get the following error in the terminal:
jest-haste-map: watch error: Error: ENOENT: no such file or directory,
open '/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting-
plus/PostingPlus/node_modules/jest-haste-map/build/worker.js' at Error
(native) at Object.fs.openSync (fs.js:640:18) at Object.fs.readFileSync
(fs.js:508:33) at Module._extensions..js (module.js:578:20) at
Object.require.extensions.(anonymous function) [as .js]
(/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting-
plus/PostingPlus/node_modules/babel-register/lib/node.js:152:7) at
Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at
Function.Module._load (module.js:438:3) at Module.require
(module.js:497:17) at require (internal/module.js:20:19)
and this error as well:
/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting-
plus/PostingPlus/node_modules/react-native/jest/hasteImpl.js:50 ) /*:
string | void */ { ^ SyntaxError: Unexpected token ) at
Object.exports.runInThisContext (vm.js:76:16) at Module._compile
(module.js:542:28) at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at
Function.Module._load (module.js:438:3) at Module.require
(module.js:497:17) at require (internal/module.js:20:19) at Object.
<anonymous> (/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting-
plus/PostingPlus/node_modules/jest-runtime/node_modules/jest-haste-
map/build/worker.js:16:19) at next (native)
I can see the worker.js file in my node_modules folder, which is why the ENOENT error is confusing.
A solution is to make sure node 8 or higher is installed. This error occurs on node 6.9.1.