Require on NodeJS angularJS framwork


#1

Hi,
I work on a webSite using angularJS and NodeJS and i try to connect to CosmoDB DataBase(SQL API) on AZURE like explaned here : https://docs.microsoft.com/fr-fr/azure/cosmos-db/sql-api-nodejs-get-started
The problem is “require” ====> i have the error : ReferenceError: require is not defined
at http://localhost:8000/app.js:41:26

I tested with browserify but the same problem.
Please helpe me.


#2

Please share your project name so we can take a look at your code (if it’s private, make it public or DM us a join link). Thanks.


#3

I cloned this projects : https://github.com/mgechev/angular-seed
And I added the config.js file wich containing :
config.endpoint = “MY URI”;
config.primaryKey = “MY AZURE COSMOS KEY”;

config.database = {
“id”: “FamilyDB”
};

config.collection = {
“id”: “FamilyColl”
};

config.documents ={…}
module.exports = config;

App.js contain :

/////////////////////////////
‘use strict’;
// Declare app level module which depends on views, and components

angular.module(‘myApp’, [
‘ngRoute’,
‘myApp.view1’,
‘myApp.view2’,
‘myApp.view3’,
‘myApp.view4’,
‘myApp.version’
]).

config([’$locationProvider’, ‘$routeProvider’, function($locationProvider, $routeProvider) {
var DocumentDBClient = require(‘documentdb’).DocumentClient;
var config = require(’./config’);

$locationProvider.hashPrefix('!');

$routeProvider.otherwise({redirectTo: '/view1'});

}]);


#4

I tried to use browserify like this : browserify -r documentdb -r ./app/app.js:documentdb > bundle.js ;
It create the bundle.js file containing require function but it don’t work…