Giter VIP home page Giter VIP logo

nodejs-getting-started's Introduction

Getting started with Node.js on Google Cloud Platform

This repository contains the complete sample code for the [Node.js Getting Started on Google Cloud Platform][getting-started] tutorials. Please refer to the tutorials for instructions on configuring, running, and deploying these samples.

The code for each tutorial is in an individual folder in this repository.

Contributing changes

Run the tests

  • Make sure you're authenticated with the gcloud SDK and your GCP project has enabled all the APIs used by these tutorials.
  • Make sure you've got the required environment variables set.
  • Replace below with the directory you want to perform tests in.
git clone [email protected]:GoogleCloudPlatform/nodejs-getting-started.git
cd nodejs-getting-started
cd <package-name>
npm install
npm test

Licensing

nodejs-getting-started's People

Contributors

ahmetb avatar allenday avatar andreban avatar asciimike avatar bcoe avatar bshaffer avatar chingor13 avatar engelke avatar feywind avatar fhinkel avatar gebeater avatar google-cloud-policy-bot[bot] avatar jasonborg avatar jmdobry avatar justinbeckwith avatar parzhitsky avatar renovate-bot avatar renovate[bot] avatar rogerthatdev avatar seanmcbreen avatar shollyman avatar sofisl avatar staskie avatar steren avatar steveperry-53 avatar thebrengun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-getting-started's Issues

Store sessions in a centralized database

The tutorial mentions at "Authenticate users / Understand the Code" that sessions should be stored in a centralized database.

In production, you should use a centralized database to store sessions securely. Google Cloud Platform makes it easy to deploy many databases, including Redis or Memcache.
https://cloud.google.com/nodejs/getting-started/authenticate-users#about_sessions

May I ask you for some help and clarify why I should do this, and how that would be implemented in the current example?

For example does it mean not to use the nodejs cookie-session module at all, or, does it just mean that sensitive information should not be stored in the local cookie but on the remote database?

model-datastore has incorrect syntax for pulling books that are "mine"

the syntax in the current file books/model-datastore.js is

  var q = ds.createQuery([kind])
    .filter('createdById =', userId)
    ...

but should instead be (note the filter):

  var q = ds.createQuery([kind])
    .filter('createdById', '=', userId)
    ...

unless support for the former way will appear in the google datastore API.

Unable to connect to Cloud SQL

I can't connect from App Engine to Cloud SQL by unix socket nor by TCP.

var mysql = require('mysql');
var mysqlConf = {
  user: 'root',
  password: '',
  socketPath: '/cloudsql/<appli-id>:<instance>',
  database: 'myDb'
};

connection = mysql.createConnection(mysqlConf);

connection.connect(function(err) {
  if (err)
    return callback(err);
  return callback();
});

it throws :

   Error: connect ENOENT
        at exports._errnoException (util.js:746:11)
        at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)

I'm using Nodejs 4.1.1.

Also I have no problem to connect to Cloud SQL from my localhost through TCP.

Am I missing something?

502 Bad Gateway / Redirect Loop after login

Hi thanks for this great tutorial.

I cloned the example and deployed it as (changed the variables as stated in the tutorial).

When I click the login button or My Books, I get a 502 Bad Gateway / Redirect Loop after confirming the consent screen.

Idea what this could be?

Need help?

Ping me if you need help with anything :)

CommandLoadFailure: Problem loading gcloud.preview.app.get_resource_limits: No module named appengine.api. (For 1-hello-world)

--> gcloud preview app                                                                                            
Traceback (most recent call last):
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/gcloud/gcloud.py", line 194, in main
    _cli.Execute()
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/cli.py", line 534, in Execute
    args = self.__parser.parse_args(args)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 73, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 64, in parse_known_args
    args, argv = super(ArgumentParser, self).parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1735, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1944, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1900, in consume_positionals
    take_action(action, args)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1809, in take_action
    action(self, namespace, argument_values, option_string)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 268, in __call__
    parser, namespace, values, option_string=option_string)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1111, in __call__
    namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 64, in parse_known_args
    args, argv = super(ArgumentParser, self).parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1735, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1944, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1900, in consume_positionals
    take_action(action, args)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1809, in take_action
    action(self, namespace, argument_values, option_string)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 268, in __call__
    parser, namespace, values, option_string=option_string)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1111, in __call__
    namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 64, in parse_known_args
    args, argv = super(ArgumentParser, self).parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1735, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "<PATH>/google-cloud-sdk/././lib/argparse/__init__.py", line 1952, in _parse_known_args
    self.error(_('too few arguments'))
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 188, in error
    self._calliope_command, self._calliope_command.ai)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/usage_text.py", line 381, in ShortHelpText
    command.LoadAllSubElements()
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 978, in LoadAllSubElements
    element = self.LoadSubElement(name)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 1018, in LoadSubElement
    self.SubParser(), parent_group=self)
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 1070, in __init__
    self._GetModuleFromPath(module_dir, module_path, path, construction_id),
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/calliope/backend.py", line 726, in _GetModuleFromPath
    module = imp.load_module(name, f, file_path, items)
  File "<PATH>/google-cloud-sdk/./lib/googlecloudsdk/appengine/app_commands/get_resource_limits.py", line 6, in <module>
    from googlecloudsdk.appengine.lib import appengine_client
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/appengine/lib/appengine_client.py", line 14, in <module>
    from googlecloudsdk.appengine.lib.external.api import appinfo
  File "<PATH>/google-cloud-sdk/././lib/googlecloudsdk/appengine/lib/external/api/appinfo.py", line 33, in <module>
    from google.appengine.api import pagespeedinfo
CommandLoadFailure: Problem loading gcloud.preview.app.get_resource_limits: No module named appengine.api.

Was following https://cloud.google.com/nodejs/getting-started/hello-world#download_app, and at the time of deployment - it fails.

Please guide.

Thanks

What configuration are available?

Have been using nodejs based app-engine runtime to deploy and recently it started showing this warning:

Verifying that Managed VMs are enabled and ready.
Building and pushing image for service [default]
WARNING: No configuration information provided by runtime [nodejs].

In my package.json engines is already specified. Any more configurations I might be missing, or can make use of?

Add a note explaining why kerberos is a dependency

It seemed like an unused dependency, and when I searched the repo I couldn't find any mention of what it was for. After googling it, I found out it was apparently required by mongodb for some systems?

I think making a note of that in the structured data tutorial would be helpful.

gcloud preview app run ./app.yaml throwing error

Seems to be caused by an unknown RuntimeError.

RuntimeError: Unknown runtime 'nodejs'; supported runtimes are 'custom', 'go', 'java', 'java7', 'php', 'php55', 'python', 'python27', 'vm'.

Runs fine when executing on google.

gcloud preview app deploy app.yaml --set-default 
➜  1-hello-world git:(1-hello-world)  gcloud --verbosity debug preview app run ./app.yaml
DEBUG: Running gcloud.preview.app.run with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.preview.app.run', usage=None, description="*(BETA)* This command is used to run one or more of your modules in the local\ndevelopment application server.  This allows you to test and debug your app\nbefore deploying.  As an input it takes one or more ``RUNNABLES'' that should\nbe run locally.  A ``RUNNABLE'' can be a module's .yaml file, or a directory.\nIf given a directory, all modules found will be run.  You can run multiple\nmodules at the same time, even if they are implemented in different languages.", version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), admin_host=None, allow_skipped_files=False, api_host=None, appidentity_email_address=None, appidentity_private_key_path=None, auth_domain='gmail.com', blobstore_path=None, clear_datastore=False, cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x10d869690>>, command_path=['gcloud', 'preview', 'app', 'run'], custom_entrypoint=None, datastore_consistency_policy='time', datastore_path=None, default_gcs_bucket_name=None, document=None, enable_cloud_datastore=False, enable_mvm_logs=False, enable_sendmail=False, format=None, h=None, help=None, host=None, http_timeout=None, jvm_flag=None, log_http=None, log_level=None, logs_path=None, markdown=None, max_module_instances=None, php_executable_path=None, project=None, python_startup_script=None, quiet=None, require_indexes=False, runnables=['./app.yaml'], show_mail_body=False, smtp_allow_tls=False, smtp_host=None, smtp_password=None, smtp_user=None, storage_path=None, trace_token=None, use_mtime_file_watcher=False, user_output_enabled=None, verbosity='debug', version=None).
DEBUG: Found Cloud SDK root: /Users/elliottgarcea/google-cloud-sdk
DEBUG: Found App Engine SDK root: /Users/elliottgarcea/google-cloud-sdk/platform/google_appengine
Module [default] found in file [/Users/elliottgarcea/Workspace/1-hello-world/app.yaml]
INFO: Looking for the Dockerfile in /Users/elliottgarcea/Workspace/1-hello-world
INFO: Using Dockerfile found in /Users/elliottgarcea/Workspace/1-hello-world
DEBUG: Running [dev_appserver.py] with: --allow_skipped_files=False --application=client-server-test --auth_domain=gmail.com --clear_datastore=False --datastore_consistency_policy=time --dev_appserver_log_level=debug --enable_cloud_datastore=False --enable_mvm_logs=False --enable_sendmail=False --log_level=debug --require_indexes=False --show_mail_body=False --skip_sdk_update_check=True --smtp_allow_tls=False --use_mtime_file_watcher=False /Users/elliottgarcea/Workspace/1-hello-world/app.yaml
INFO     2015-08-07 20:37:48,516 application_configuration.py:399] No version specified. Generated version id: 20150807t203748
INFO     2015-08-07 20:37:48,516 devappserver2.py:763] Skipping SDK update check.
DEBUG    2015-08-07 20:37:48,560 app_identity_stub.py:197] Successfully loaded Application Default Credentials.
INFO     2015-08-07 20:37:48,567 api_server.py:205] Starting API server at: http://localhost:61437
INFO     2015-08-07 20:37:48,568 api_server.py:646] Applying all pending transactions and saving the datastore
INFO     2015-08-07 20:37:48,568 api_server.py:649] Saving search indexes
Traceback (most recent call last):
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 83, in <module>
    _run_file(__file__, globals())
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 79, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1033, in <module>
    main()
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1026, in main
    dev_server.start(options)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 818, in start
    self._dispatcher.start(options.api_host, apis.port, request_data)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 193, in start
    _module, port = self._create_module(module_configuration, port)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 278, in _create_module
    threadsafe_override=threadsafe_override)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1536, in __init__
    super(ManualScalingModule, self).__init__(**kwargs)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 555, in __init__
    self._module_configuration)
  File "/Users/elliottgarcea/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 251, in _create_instance_factory
    sorted(repr(k) for k in self._RUNTIME_INSTANCE_FACTORIES))))
RuntimeError: Unknown runtime 'nodejs'; supported runtimes are 'custom', 'go', 'java', 'java7', 'php', 'php55', 'python', 'python27', 'vm'.
DEBUG: Error [1] while running DevAppSever with: [--allow_skipped_files=False --application=client-server-test --auth_domain=gmail.com --clear_datastore=False --datastore_consistency_policy=time --dev_appserver_log_level=debug --enable_cloud_datastore=False --enable_mvm_logs=False --enable_sendmail=False --log_level=debug --require_indexes=False --show_mail_body=False --skip_sdk_update_check=True --smtp_allow_tls=False --use_mtime_file_watcher=False /Users/elliottgarcea/Workspace/1-hello-world/app.yaml]
DEBUG: (gcloud.preview.app.run) DevAppSever failed with error code [1]
Traceback (most recent call last):
  File "/Users/elliottgarcea/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 548, in Execute
    result = args.cmd_func(cli=self, args=args)
  File "/Users/elliottgarcea/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1102, in Run
    result = command_instance.Run(args)
  File "/Users/elliottgarcea/google-cloud-sdk/./lib/googlecloudsdk/appengine/app_commands/run.py", line 334, in Run
    runner.Start(*runnables)
  File "/Users/elliottgarcea/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/dev_appserver_adapter.py", line 138, in Start
    raise DevappserverExecutionError(return_code, argv)
DevappserverExecutionError: DevAppSever failed with error code [1]
ERROR: (gcloud.preview.app.run) DevAppSever failed with error code [1]

memcached address:port is no longer correct as set in production

the old setting here in app.js wasn't working for me:

if (config.get('NODE_ENV') === 'production') {
  sessionConfig.store = new MemcachedStore({
    hosts: [config.get('MEMCACHE_URL')]
  });
}

this seems to work, though there's probably a prettier way to do it (maybe config.json can put these two environment variables together into MEMCACHE_URL):

if (config.get('NODE_ENV') === 'production') {
  var memAddr = process.env.MEMCACHE_PORT_11211_TCP_ADDR;
  var memPort = process.env.MEMCACHE_PORT_11211_TCP_PORT;
  if (!memAddr || !memPort) {
    sessionConfig.store = new MemcachedStore({
      hosts: [config.get('MEMCACHE_URL')]
    });
    return;
  }
  sessionConfig.store = new MemcachedStore({
    hosts: [memAddr + ":" + memPort]
  });
}

Getting DB connection error as soon as I hit the app url locally

App listening at http://0.0.0.0:8080
Press Ctrl+C to quit.
/Users/dutishan/Documents/2-structured-data/node_modules/mongodb/lib/server.js:228
process.nextTick(function() { throw err; })
^
TypeError: Cannot read property 'find' of undefined
at /Users/dutishan/Documents/2-structured-data/books/model-mongodb.js:55:17
at /Users/dutishan/Documents/2-structured-data/books/model-mongodb.js:45:23
at /Users/dutishan/Documents/2-structured-data/node_modules/mongodb/lib/mongo_client.js:236:20
at /Users/dutishan/Documents/2-structured-data/node_modules/mongodb/lib/db.js:203:14
at null. (/Users/dutishan/Documents/2-structured-data/node_modules/mongodb/lib/server.js:226:9)

04-auth MEMCACHE_URL

Not working in this step.

I believe I have set the Credential correctly and I also set the MEMCACHE_URL after I created a redis from Redis Lab.

The production website is online after I depoy. But if I click login, it takes long time to loading and get 502 Bad Gateway at the end

Error: Cannot find module '/Users/chr/dev/nodejs-getting-started/3-binary-data/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node'

Hi,

Due to security flaws, current best practise for an npm install appears to be:

npm install --ignore-scripts

For chapter 3-binary-data, I'm having trouble installing with the ignore-scripts flag. Under node v 6.0.0 & v 4.2.1

Error: Cannot find module '/Users/chr/dev/nodejs-getting-started/3-binary-data/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node'

Add tests for data storage samples

Data storage samples (i.e. Cloud SQL, Datastore, MongoDB) should test that they can interact with their relevant storage methods properly.

what's the nodejs version of the nodejs runtime?

what will be the version used in the vm by setting runtime: nodejs in app.yaml?
Will it refer my package.json for the version?
If no, any ways that I can config it except using custom Docker?

Missing config-default.json file in 05 and 06

In the README of both 05 and 06, there is this line :
Create a config.json file (copied from the config-default.json file):
But I can't find a file named config-default.json in 05 nor in 06. What should I do ?

Using Cloud SQL with Node.js => "Error: connect ETIMEDOUT" on App Engine

Hi,

When I follows all the steps of the turorial Using Cloud SQL with Node.js, I have a error after the step "Deploying the app to the App Engine flexible environment".

When the Node.js application runs on my local machine (step "Running the app on your local machine"), they isn't any problem connecting and using the MySQL (Second Generation) instance.
But when the Node.js application is deployed on the App Engine, I immediately have this following error:
{ [Error: connect ETIMEDOUT]
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true,
response: 'connect ETIMEDOUT' }

In fact, it's working when I add the 0.0.0.0/0 IP address to the Authorized Networks section but how to do in a production environment?

Thanks for you help!

Doesn't appear to work with yarn

Trying to use yarn in 3-binary-data. Installed deps with yarn, and then ran gcloud app deploy:

beckwith-macbookpro:3-binary-data beckwith$ gcloud app deploy -q
You are about to deploy the following services:
 - compute-summit/default/20170206t215346 (from [/Users/beckwith/Code/nodejs-getting-started/3-binary-data/app.yaml])
     Deploying to URL: [https://compute-summit.appspot.com]

If this is your first deployment, this may take a while...done.                                                                                                             

Beginning deployment of service [default]...
WARNING: Deployment of App Engine Flexible Environment apps is currently in Beta
Building and pushing image for service [default]
WARNING: detect: error Integrity hashes don't match, expected "6fcb8103d6dcaf68cfac1827c88f8535c358fb2fac565f2af79cfeb04633bb57" but got "9979ecaf94f39fc1bff9c7fac76106080de4d3adbc60c558bd305e96ea50dae8"
WARNING: detect: error Found 1 errors.
ERROR: Yarn checker: "yarn.lock" was found indicating Yarn is being used, but "yarn check" indicates "yarn.lock" is invalid.
ERROR: (gcloud.app.deploy) Your application does not satisfy all of the requirements for a runtime of type [nodejs].  Please correct the errors and try again.
beckwith-macbookpro:3-binary-data beckwith$ yarn check
yarn check v0.19.1
error "jade#uglify-js@^2.4.19" doesn't satisfy found match of "[email protected]"
warning "\u001b[2mmysql#\u001b[22mreadable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "mongodb#readable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "duplexify#readable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "through2#readable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "concat-stream#readable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "superagent#readable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "base64url#concat-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
warning "bl#readable-stream#inherits@~2.0.1" could be deduped from "2.0.3" to "[email protected]"
info Found 8 warnings.
error Found 1 errors.
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

Error installing dependencies (grpc)

my machine: macOs 10.11.6 (El Capitan) - node v7.0.0 - npm v3.10.8
I tried doing npm install but it failed with the following error:

npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1

Below I attached the screenshots:
screen shot 2017-01-04 at 19 02 52
screen shot 2017-01-04 at 19 02 27

7-gce: "npmERR! ...Parsing error: Unexpected token :"

Operating System: Windows 7* 64-bit
gcloud -v = Google Cloud SDK 146.0.0
node -v = v6.9.1
npm -v = 4.3.0

After following all the instructions for Running the Node.js Bookshelf on Compute Engine, I'm getting the following error: C:\Program Files (x86)\Google\Cloud SDK\nodejs-getting-started\7-gce\config.js:3:15: Parsing error: Unexpected token : The error is preceded by the path to my Cloud SDK installation, and the error occurs when I run npm test from the nodejs-getting-started directory, and I get a similar error when I run npm start from the 7-gce directory.

I'm guessing it has something to do with /7-gce/config.js ...?

One thing I noticed from the tutorial:

  • config.js comes prepared with additional configurations, yet in the tutorial when Configuring the app the instructions are to "...create a config.json file with this content:". At first, copied config.js to config.original.js, and put the values in the existing file, and received similar errors, so then I copied and pasted (as instructed) the format that was provided. It would be great if the tutorial, or or 7-gce README.md file clarified the recommeding procedure.

Here is the output to the command line, from the log file:
17 error Windows_NT 6.1.7601
18 error argv "C:\Program Files\nodejs\node.exe" "C:\Users\my-user-name\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "lint"
19 error node v6.9.1
20 error npm v4.3.0
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] lint: semistandard "**/*.js"
23 error Exit status 1
24 error Failed at the [email protected] lint script 'semistandard "/*.js"'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the nodejs-getting-started package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error semistandard "
/*.js"
24 error You can get information on how to open an issue for this project with:
24 error npm bugs nodejs-getting-started
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls nodejs-getting-started
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]

UPDATE: I downloaded the lasted Node.js MSI - no change in results. I tried one more fix... when I run npm test with the config.js in it's original format (from this repository) and with my values, npm test is able to go one step further, than with the format from the tutorial.

  • npm run lint && npm run cover
  • semistandard "**/*.js"
  • instabul cover --hook-run-in-context node_modules/mocha/bin/__mocha --test/index.js -t 30000
    After some additional output, the output indicates "You must set GCLOUD_PROJECT as an environmental variable or in config.json" - even though it is set in the config.js file.

I really hope there is some oversight on my part, because I'm stumped!

npm install fails on Windows

I am not having an easy time following the tutorial

My system

  • Windows 10 x64
  • All visual studio packages possible installed (not really, but I at least installed 2015 several times)
  • Node 6.2, NPM 3.8.9
  • I also tried Node 4.4.4 because of this note and saw issues with sse4_crc32 when rebuilding node-gyp.

NPM install Errors

  • I attached the log file. Seems related to gprc.
  • Some shell output:

node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\johnk_000\Documents\google-cloud-platform\nodejs-getting-started\2-structured-data\node_modules\grpc\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\johnk_000\Documents\google-cloud-platform\nodejs-getting-started\2-structured-data\node_modules\grpc
node-pre-gyp ERR! node -v v6.2.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.25
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\johnk_000\Documents\google-cloud-platform\nodejs-getting-started\2-structured-data\node_modules\grpc\src\node\extension_binary\grpc_node.node --module_name=grpc_node --module_path=C:\Users\johnk_000\Documents\google-cloud-platform\nodejs-getting-started\2-structured-data\node_modules\grpc\src\node\extension_binary' (1)
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm
npm-debug.zip
ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the grpc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs grpc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls grpc
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\johnk_000\Documents\google-cloud-platform\nodejs-getting-started\2-structured-data\npm-debug.log

Wondering:: books/api.js for What?

Hello, I'm learning 'mean' stack theseday, I follow google cloud node.js start guide line, so I made sample application using your codes. I have to delve into codes, to know how it works.

But, I don't know why books/api.js comes up. Is this just an api? I delete it and test at local, but It doesn't matters. Can you explain its roles?

catch Exceptions in pubsub

From @mytholog on August 3, 2016 8:37

Environment details

  • OS: Mac (Capitan)
  • Node.js version: 4.4.7
  • gcloud-node version: 0.37.0

Steps to reproduce

  1. require gcloud-node
  2. run code from https://github.com/GoogleCloudPlatform/nodejs-getting-started/tree/master/6-pubsub
"stack":[
  "Error: Deadline Exceeded",
  " at Function.GrpcService.decorateError_ (/node_modules/gcloud/lib/common/grpc-service.js:482:34)",
  " at Object.callback (/node_modules/gcloud/lib/common/grpc-service.js:247:35)",
  " at /node_modules/gcloud/node_modules/grpc/src/node/src/client.js:420:14"
],
"level":"error",
"message":"uncaughtException: Deadline Exceeded"

Copied from original issue: googleapis/google-cloud-node#1465

3-binary-data: Cannot upload image

If I enter just form data, it is working fine. But if I try to upload image, The action is simple redirecting to 'NOT Found'.

The problem is coming i here:
// File: lib/images.js
stream.on('error', (err) => {
req.file.cloudStorageError = err;
next(err);
});

And the error is not clear: { errors: [ { domain: 'global', reason: 'notFound', message: 'Not Found' } ],
code: 404,
message: 'Not Found',
response: 'Not Found' }

Error deploying 6 pub-sub

When deploying tutorial 6 Pub-Sub, I get the error:
Deployed with cloud shell on the gcp website. config.js copied from prior working samples. The site for the application does come up, however the worker fails to run.

This project is using datastore for the data backed.

Updating service [worker]...failed.                                                                                                                                                                                                           
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: Deployments to App Engine Flexible require `env: flex` in app.yaml.  The `vm:true` setting has been deprecated. To learn more, please visit https://cloud.google.com/appengine/docs/flexible/python/upgrading.

This seems to be for the worker.yaml, and trying to publish node.js Other tutorials deploy correctly.
When changing the yamlto remove the vm:true, the worker deploys successfully.
Updated worker.yaml

# [START yaml]
service: worker

env_variables:
  SCRIPT: 'worker.js'

runtime: nodejs
env: flex

# Temporary setting to keep gcloud from uploading node_modules
skip_files:
 - ^node_modules$
# [END yaml]

Bug in runQuery sample code

Hello!!

I've been having some problems with the queries in datastore and I found the reason.
It's just this line of code

var hasMore = entities.length === limit ? nextQuery.startVal : false;

This fails if the entities given are the last ones. The condition is true but then nextQuery doesn't exist.

I think it should be better in this way.

// same qty or no more
var hasMore = false;
if(entities.length === limit && nextQuery)
  hasMore = nextQuery.startVal;

Uploaded Images are downloaded as application/octet-stream

On the binary-data sample, as the Content-Type is not being set on upload, images are being downloaded with the Content-Type application/octet-stream. This works for types such as png and jpg but breaks when the uploaded image is an svg.

init-cloudsql fails probably due to disabled network access

Hello!
I am trying to complete the node.js CloudSQL bookshelf tutorial on my Mac.
I have enabled the APIs, set up my project and created a first generation sql instance.
I have configured the instance as specified in the tutorial -
Named my database "library"
Allow all network access (0.0.0.0/0)
Requested ipv4
Created a user
I have also set up my config.json file with these variables -
{
"GCLOUD_PROJECT": "[MY_ID]",
"DATA_BACKEND": "cloudsql",
"MYSQL_USER": "nodejsapp",
"MYSQL_PASSWORD": "[MY_PASSWORD]",
"MYSQL_HOST": "[YOUR_MYSQL_HOST]" example 176.197.82.75
}
When I run the script it throws an error - Error: connect ETIMEDOUT, with more output.
I am guessing that this is due to blocked access as I have also tried pinging the server and it sends request timeout.
I also tried gcloud beta sql connect and that did not connect as well, although it said that it is temporary whitelisting my IP which appeared in Console.
Please help!

Bookshelf APP: Got errors at npm install

my project folder: zijihgo@sanguine-willow-112918:~/6-pubsub
Repro steps:
The Bookshelf App
After: (1) git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git -b 6-pubsub 6-pubsub
(2) cd 6-pubsub
(3)updated config.js and app.yaml as indicated at https://cloud.google.com/nodejs/getting-started/using-pub-sub
(4) npm install

I got error:
zijihgo@sanguine-willow-112918:~/6-pubsub$ npm install

[email protected] install /home/zijihgo/6-pubsub/node_modules/gcloud/node_modules/hash-stream-
validation/node_modules/fast-crc32c/node_modules/sse4_crc32
node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: read ECONNRESET
gyp ERR! stack at exports._errnoException (util.js:746:11)
gyp ERR! stack at TCP.onread (net.js:559:26)
gyp ERR! System Linux 3.16.0-0.bpo.4-amd64
gyp ERR! command "node" "/usr/local/nvm/versions/node/v0.12.2/lib/node_modules/npm/node_modules
/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/zijihgo/6-pubsub/node_modules/gcloud/node_modules/hash-stream-validation/nod
e_modules/fast-crc32c/node_modules/sse4_crc32
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
npm WARN peerDependencies The peer dependency kerberos@~0.0 included from mongodb-core will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.

Thanks,

Remove skipped files from app.yaml

We don't need this anymore - we do it automatically now.

# Temporary setting to keep gcloud from uploading node_modules
skip_files:
 - ^node_modules$

Cannot read property 'headers' of undefined

I hit the following snag upon trying to run the sample app locally before pushing to Google Cloud Platform.

├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
um-macbook:2-structured-data jandersen$ npm start

> [email protected] start /Users/jandersen/projects/2-structured-data
> node app.js

App listening at http://0.0.0.0:8080

/Users/jandersen/projects/2-structured-data/node_modules/gcloud/lib/common/util.js:448
  reqOpts.headers = reqOpts.headers || {};
                           ^
TypeError: Cannot read property 'headers' of undefined
    at Object.decorateRequest (/Users/jandersen/projects/2-structured-data/node_modules/gcloud/lib/common/util.js:448:28)
    at onAuthorized (/Users/jandersen/projects/2-structured-data/node_modules/gcloud/lib/common/util.js:356:32)
    at /Users/jandersen/projects/2-structured-data/node_modules/gcloud/node_modules/google-auto-auth/index.js:18:7
    at /Users/jandersen/projects/2-structured-data/node_modules/gcloud/node_modules/google-auto-auth/index.js:66:7
    at addScope (/Users/jandersen/projects/2-structured-data/node_modules/gcloud/node_modules/google-auto-auth/index.js:102:7)
    at callback (/Users/jandersen/projects/2-structured-data/node_modules/gcloud/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/googleauth.js:41:5)
    at /Users/jandersen/projects/2-structured-data/node_modules/gcloud/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/googleauth.js:124:9
    at process._tickCallback (node.js:415:13)

npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.10.22
npm ERR! npm  v2.7.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node app.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node app.js'.
npm ERR! This is most likely a problem with the nodejs-getting-started package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls nodejs-getting-started
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/jandersen/projects/2-structured-data/npm-debug.log

Error parsing protocol message

Hi,
I'd like to report a bug. It is very easy to reproduce.

Relevant info:

  • nodejs -v = v6.9.2
  • npm -v = 3.10.9

Steps:
1.- $ git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git
2.- $ cd nodejs-getting-started/
3.- $ npm install
4.- $ cd 2-structured-data/
5.- vi config.js
6.- Set the GCLOUD_PROJECT variable
7.- npm test

Output:

[email protected] test ~/nodejs-getting-started/2-structured-data
mocha test/index.js -t 30000

  2-structured-data/
    ✓ should install dependencies (3543ms)
    app.js
      ✓ should run (4921ms)
      ✓ should redirect / to /books (134ms)
      ✓ should check config (56ms)
    books/
      api.js
        ✓ should create a book (1401ms)
        ✓ should list books (1362ms)
        ✓ should delete a book (225ms)
      crud.js
        /books
          ✓ should show a list of books (2867ms)
{ Error: Error parsing protocol message
    at Function.GrpcService.decorateError_ (/home/gomezalvaro/nodejs-getting-started/2-structured-data/node_modules/@google-cloud/common/src/grpc-service.js:488:34)
    at Object.callback (/home/gomezalvaro/nodejs-getting-started/2-structured-data/node_modules/@google-cloud/common/src/grpc-service.js:247:35)
    at /home/gomezalvaro/nodejs-getting-started/2-structured-data/node_modules/grpc/src/node/src/client.js:420:14
  code: 400,
  metadata: Metadata { _internal_repr: {} },
  message: 'Error parsing protocol message',
  response: 'Error parsing protocol message' }
          ✓ should handle error (163ms)
        /books/add
          ✓ should post to add book form (295ms)
          ✓ should show add book form (97ms)
        /books/:book/edit & /books/:book
          ✓ should update a book (282ms)
RT <!DOCTYPE html><html lang="en"><head><title>Bookshelf - Node.js on Google Cloud Platform</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"></head><body><div class="navbar navbar-default"><div class="container"><div class="navbar-header"><div class="navbar-brand">Bookshelf</div></div><ul class="nav navbar-nav"><li><a href="/books">Books</a></li></ul></div></div><div class="container"><h3>Edit book</h3><form method="POST"><div class="form-group"><label for="title">Title</label><input type="text" name="title" id="title" value="my other book" class="form-control"></div><div class="form-group"><label for="author">Author</label><input type="text" name="author" id="author" class="form-control"></div><div class="form-group"><label for="publishedDate">Date Published</label><input type="text" name="publishedDate" id="publishedDate" class="form-control"></div><div class="form-group"><label for="description">Description</label><input type="text" name="description" id="description" class="form-control"></div><div class="form-group"></div><button type="submit" class="btn btn-success">Save</button></form></div></body></html>
expected <input type="text" name="title" id="title" value="my other book" class="form-control">
          ✓ should show edit book form (278ms)
          ✓ should show a book (210ms)
          ✓ should delete a book (164ms)


  15 passing (17s)_

In conclusion, error message is

_{ Error: Error parsing protocol message
    at Function.GrpcService.decorateError_ (/home/gomezalvaro/nodejs-getting-started/2-structured-data/node_modules/@google-cloud/common/src/grpc-service.js:488:34)
    at Object.callback (/home/gomezalvaro/nodejs-getting-started/2-structured-data/node_modules/@google-cloud/common/src/grpc-service.js:247:35)
    at /home/gomezalvaro/nodejs-getting-started/2-structured-data/node_modules/grpc/src/node/src/client.js:420:14
  code: 400,
  metadata: Metadata { _internal_repr: {} },
  message: 'Error parsing protocol message',
  response: 'Error parsing protocol message' }_

Let me know if you need anything else.
Best,
Alvaro

jade dependencies

upon installing, npm warns that jade has been deprecated, and renamed to pug

Add service: service_name

Hey,

Just a quick note about those sample codes. GCP doesn't allow you to delete default service, but all samples creates one.

I'd suggest adding service: service_name to each of those samples, so we can delete all created instances and start fresh.

I am happy to do a PR for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.