Importing Skygear Cloud


#1

I am trying to import skygear cloud but it keeps giving an npm error even on a fresh installation

./node_modules/pg/lib/connection-parameters.js
Module not found: Can’t resolve ‘dns’ in ‘C:\Users\me\Desktop\Work\practice\test-admin\node_modules\pg\lib’


#2

May you put the commands you run here so we can help look into it?


#3
import skygear from 'skygear';
import {
    skygearConfig
} from './config';
import skygearCloud from 'skygear/cloud'

My package.json is a basic create-react-app using react-admin


#4

What about the command you typed? And would you mind to simply zip the folder for me?

Since the error is about a node module not found I am suspecting it is something because of the packages and the command to load the modules


#5

Hey there, @bencheng. Sorry did not reply for long but moved on to a different solution. However would love to know a solution for the same question. Please check on this repo https://bitbucket.org/DaveRiveras/skygear-demo.git


#6

Sorry may you clarify what is the problem you have? What did you type or done? It seems something with the node.js environment on your computer.


#7

I’m using create-react-app on Windows 10, found that I needed packages dns and pg-native installed. pg-native installed correctly but dns failed to install correctly.

Which brought up critical dependency errors.

Could it be a OS issue?


#8

Hello David!

You got that error because you have imported skygearCloud (which is expected to be run in a node environment) in App.js (which is expected to be run in the browser).

You can check out the cloud functions guide to learn about how to work with skygearCloud: https://docs.skygear.io/guides/cloud-function/database-hooks/js/

Cheers,
Ten