简体   繁体   中英

Parse server clone install

I clone Repo parse server from parse-server-example and add run mongo db and also install nodejs pacakge via npm install , But when i want to run app with npm start print this error in terminal!!

How i can fix this issue ? it's about nodejs version or what? 在此处输入图片说明

Here is my index.js file:

 // Example express application adding the parse-server module to expose Parse // compatible API routes. var express = require('express'); var ParseServer = require('parse-server').ParseServer; var path = require('path'); var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI; var api = new ParseServer({ databaseURI: databaseUri || 'mongodb://localhost:27017/dev', cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', appId: process.env.APP_ID || 'app', masterKey: process.env.MASTER_KEY || 'master', //Add your master key here. Keep it secret! serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed liveQuery: { classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions } }); // Client-keys like the javascript key or the .NET key are not necessary with parse-server // If you wish you require them, you can set them as options in the initialization above: // javascriptKey, restAPIKey, dotNetKey, clientKey var app = express(); // Serve static assets from the /public folder app.use('/public', express.static(path.join(__dirname, '/public'))); // Serve the Parse API on the /parse URL prefix var mountPath = process.env.PARSE_MOUNT || '/parse'; app.use(mountPath, api); // Parse Server plays nicely with the rest of your web routes app.get('/', function(req, res) { res.status(200).send('Make sure to star the parse-server repo on GitHub!'); }); // There will be a test page available on the /test path of your server url // Remove this before launching your app app.get('/test', function(req, res) { res.sendFile(path.join(__dirname, '/public/test.html')); }); var port = process.env.PORT || 1337; var httpServer = require('http').createServer(app); httpServer.listen(port, function() { console.log('parse-server-example running on port ' + port + '.'); }); // This will enable the Live Query real-time server ParseServer.createLiveQueryServer(httpServer); 

And by install babel-cli and run show me this:

 /Users/sajad/Sites/parse/node_modules/parse-server/node_modules/babel-polyfill/lib/index.js:14 throw new Error("only one instance of babel-polyfill is allowed"); ^ Error: only one instance of babel-polyfill is allowed at Object.<anonymous> (/Users/sajad/Sites/parse/node_modules/parse-server/node_modules/babel-polyfill/lib/index.js:14:9) at Module._compile (module.js:460:26) at Module._extensions..js (module.js:478:10) at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:134:7) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/Users/sajad/Sites/parse/node_modules/parse-server/lib/ParseServer.js:9:1) at Module._compile (module.js:460:26) 

This is because this module(or more correctly, a dependency of your module) is using the const keyword which isn't available in your node version (v0.12). Full support for the const keyword came in v6 of node which arrived just this week.

Alternatively you could transpile your project using babel

If you go with the babel route you could do the following in your project root folder

npm install -g babel-cli
babel-node index.js

See babel usage page for more information on how to use babel correctly.

EDIT: In the documentation you provided it explicitly tells you that you must have at least node v4.3 and that you should run the project with the command "npm start". So i'm guessing that this project already has babel, you're just running it incorrectly and with the incorrect node version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM