3035app / pialab

PiaLab Angular app
http://www.pialab.io/
GNU General Public License v3.0
26 stars 8 forks source link

stuck on install : ng serve giving out errors #8

Closed QuentinBibas closed 6 years ago

QuentinBibas commented 6 years ago

Summary

When trying to start ng serve after installing node.js and angular/CLI globally, the command gives out many errors, including a wrong version type

Steps to reproduce

on any new Ubuntu 16.04 LTS install (which was the suggested OS for original PIA-front) :

Git clone pialab
install nvm
nvm install lts/carbon #node version 8.11.2 & npm 5.10.0
npm install -g @angular/CLI 
cd pialab
ng serve

Expected behavior

no clue what should happen start a server in dev mode ?

Actual behavior

~/pialab# ng serve
Your global Angular CLI version (6.0.3) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:15457:110)
    at parseSourceFileWorker (/root/pialab/node_modules/typescript/lib/typescript.js:15389:26)
    at Object.parseSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:15338:26)
    at Object.createSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:15192:29)
    at VirtualFileStats.getSourceFile (/root/pialab/node_modules/@ngtools/webpack/src/compiler_host.js:67:35)
    at WebpackCompilerHost.getSourceFile (/root/pialab/node_modules/@ngtools/webpack/src/compiler_host.js:206:38)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67909:29)
    at processImportedModules (/root/pialab/node_modules/typescript/lib/typescript.js:68056:25)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67937:17)
    at processImportedModules (/root/pialab/node_modules/typescript/lib/typescript.js:68056:25)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67937:17)
    at processImportedModules (/root/pialab/node_modules/typescript/lib/typescript.js:68056:25)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67937:17)
    at processSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67840:27)
    at processRootFile (/root/pialab/node_modules/typescript/lib/typescript.js:67728:13)
    at /root/pialab/node_modules/typescript/lib/typescript.js:67018:60
~/pialab# npm install @angular/CLI@1.7.4
npm ERR! code E404
npm ERR! 404 Not Found: @angular/CLI@1.7.4

versions

ubuntu server 16.04 LTS (minimal install) nvm 8.11.2 node 8.11.2 npm 5.10.2 angular/cli 6.0.3

RomainSanchez commented 6 years ago

@QuentinBibas You need to run npm install for the project dependencies to be installed before running ng serve Hope that helps

QuentinBibas commented 6 years ago

same error, sadly

~/pialab# npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

up to date in 9.069s
[!] 23 vulnerabilities found [7073 packages audited]
    Severity: 11 Low | 5 Moderate | 6 High | 1 Critical
    Run `npm audit` for more detail

~/pialab# ng serve
Your global Angular CLI version (6.0.3) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:15457:110)
    at parseSourceFileWorker (/root/pialab/node_modules/typescript/lib/typescript.js:15389:26)
    at Object.parseSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:15338:26)
    at Object.createSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:15192:29)
    at VirtualFileStats.getSourceFile (/root/pialab/node_modules/@ngtools/webpack/src/compiler_host.js:67:35)
    at WebpackCompilerHost.getSourceFile (/root/pialab/node_modules/@ngtools/webpack/src/compiler_host.js:206:38)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67909:29)
    at processImportedModules (/root/pialab/node_modules/typescript/lib/typescript.js:68056:25)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67937:17)
    at processImportedModules (/root/pialab/node_modules/typescript/lib/typescript.js:68056:25)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67937:17)
    at processImportedModules (/root/pialab/node_modules/typescript/lib/typescript.js:68056:25)
    at findSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67937:17)
    at processSourceFile (/root/pialab/node_modules/typescript/lib/typescript.js:67840:27)
    at processRootFile (/root/pialab/node_modules/typescript/lib/typescript.js:67728:13)
    at /root/pialab/node_modules/typescript/lib/typescript.js:67018:60
RomainSanchez commented 6 years ago

Right.Give us a bit of time to investigate we'll keep you posted

PapsOu commented 6 years ago

Hi.

Could you try the following manipulation and tell me if it works :

cp src/environments/environment.prod.ts.example src/environments/environment.dev.ts

You must change values of this file according to the backend configuration

PapsOu commented 6 years ago

Are you using our Symfony 4 backend https://github.com/pia-lab/pialab-back ?

QuentinBibas commented 6 years ago

just tried that, set version to "dev"

ng serve tried to compile, then bugged out at 90%

ng serve
Your global Angular CLI version (6.0.3) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-05-24T10:47:06.049Z
Hash: f8107b54f062813192f1
Time: 27903ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 2.2 MB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 605 kB [initial] [rendered]
chunk {scripts} scripts.bundle.js (scripts) 1.3 MB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 471 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 16.8 MB [initial] [rendered]

ERROR in /root/pialab/src/api/service/base.service.ts (13,32): Property 'api' does not exist on type '{ name: string; production: boolean; version: string; rollbar_key: string; }'.
ERROR in /root/pialab/src/app/services/authentication.service.ts (10,46): Property 'api' does not exist on type '{ name: string; production: boolean; version: string; rollbar_key: string; }'.
ERROR in /root/pialab/src/app/services/authentication.service.ts (11,45): Property 'date_format' does not exist on type '{ name: string; production: boolean; version: string; rollbar_key: string; }'.
ERROR in /root/pialab/src/app/authentication/authentication.component.ts (20,35): Property 'api' does not exist on type '{ name: string; production: boolean; version: string; rollbar_key: string; }'.

webpack: Failed to compile.

pialab-back is already installed and waiting

QuentinBibas commented 6 years ago

pialab back working ok :

 GET http://localhost:8000/oauth/v2/token
<HTML><HEAD>

<TITLE>Erreur réseau</TITLE>

<SCRIPT LANGUAGE="JavaScript">

var table_eng = new Array();

var table_fr = new Array();

var table = new Array();

table_eng = ["none","unavailable","Abortion","Adult/Mature Content","Alcohol", "Alternative Sexuality/Lifestyles", "Alternative Spirituality/Belief", "Art/Culture", "Auctions", "Audio/Video Clips", "Blogs/Personal Pages", "Brokerage/Trading", "Business/Economy", "Charitable Organizations", "Chat/Instant Messaging", "Child Pornography", "Computers/Internet", "Content Servers", "Dynamic DNS Host", "Education", "Email", "Entertainment", "Extreme", "Financial Services", "For Kids", "Gambling", "Games", "Government/Legal", "Greeting Cards", "Hacking", "Health", "Humor/Jokes", "Illegal Drugs", "Informational", "Illegal/Questionable", "Internet Telephony", "Intimate Apparel/Swimsuit", "Job Search/Careers", "LGBT", "Malicious Sources", "Malicious Outbound Data/Botnets", "Media Sharing", "Military", "News/Media", "Newsgroups/Forums", "Non-viewable", "Nudity", "Online Meetings", "Online Storage", "Open/Mixed Content", "Pay to Surf", "Peer-to-Peer (P2P)", "Personals/Dating", "Phishing", "Placeholders", "Political/Activist Groups", "Pornography", "Potentially Unwanted Software", "Proxy Avoidance", "Real Estate", "Reference", "Religion", "Remote Access Tools", "Restaurants/Dining/Food", "Scam/Questionnable/Ilegal", "Search Engines/Portals", "Sex Education", "Shopping", "Social Networking", "Society/Daily Living", "Software Downloads", "Spam", "Sports/Recreation", "Suspicious", "TV/Video Streams", "Tobacco", "Translation", "Travel", "Uncategorized", "Vehicles", "Violence/Hate/Racism", "Weapons", "Web Advertisements", "Web Application", "Web Hosting"];

table_fr = ["Non Trouvée","Non Disponible","Avortement","Contenu Adulte/Mature", "Alcool", "Sexualité Alternative/Style de Vie", "Spiritualité Alternative/Croyance", "Art/Culture", "Enchères", "Audio/Clips Video", "Blogs/Pages Perso", "Courtage/Négoce", "Business/Economie", "Organisations Charitatives", "Chat/Messagerie Instantanée", "Pédophilie", "Informatique/Internet", "Serveurs de Contenu", "DNS dynamique", "Education", "Email", "Divertissement", "Extrème", "Services Financiers", "Pour les Enfants", "Jeux d'Argent", "Jeux", "Gouvernement/Juridique", "Cartes de Voeux","Hacking", "Santé", "Humour/Blagues", "Illégal/Médicaments", "Informations", "Illégal/Questionable", "Téléphonie Internet", "Habillement Intime/Maillot", "Recherche d'Emploi/Carrières", "LGBT", "Sources de malwares", "Données malicieuses sortantes/Botnets", "Partage de Données", "Militaire", "Nouvelles/Médias", "Groupes de discussion/Forums", "Non-visible", "Nudité", "Meetings en Ligne", "Stockage en Ligne", "Ouvert/Contenu Varié", "Payer pour Surfer", "Peer-to-Peer", "Personels/Dating", "Phishing", "Espaces", "Politiques/Groupes d'Activistés", "Pornographie", "Logiciel Potentiellement Indésirable", "Contournement de Proxy", "Immobilier", "Référence", "Religion", "Outils d'Accès Distant", "Restaurants/Nourriture", "Arnaque/Douteux/Illégal", "Moteurs de recherche/Portails", "Education Sexuelle", "Shopping", "Réseau Social", "Société/Vie Quotidienne", "Téléchargements de Logiciels", "Spam", "Sports/Loisirs", "Suspicieux", "TV/Streams Video", "Tabac", "Traduction", "Voyage", "Non Catégortisé", "Véhicules", "Violence/Haine/Racisme", "Armes", "Annonces Web", "Application Web", "Hebergement Web "];

var i = 1;

while(table_eng[i])

{ table[table_eng[i]]=table_fr[i];i++;}

</SCRIPT>

</HEAD>

<body bgcolor="#ff9900" text="#333333">

<big><strong></strong></big><BR>

<blockquote>

<TABLE border=0 cellPadding=1 width="80%">

<TR><TD>

<FONT size=6>

<big><b>Erreur réseau (dns_unresolved_hostname)</b></big>

</FONT>

<BR>

<BR>

</TD></TR>

<TR><TD>

Le nom de domaine que vous demandez "localhost" ne semble pas être valide.

</TD></TR>

<TR><TD>

</TD></TR>

<TR><TD>

<FONT SIZE=2>

<BR>

Si vous avez besoin d'aide, contactez votre support. Merci de leur transmettre les informations contenues sur <a href=http://aide.aphp.fr>la page d'aide</a>.

<BR><BR>

</FONT>

</TD></TR>

</TABLE>

</blockquote>

</BODY></HTML>

image

PapsOu commented 6 years ago

You must create the environment file named environment.dev.ts in order to angular to work.

Because angular will load it (see file https://github.com/pia-lab/pialab/blob/master/.angular-cli.json#L42)

Your backend does not seem sto work properly because of network configuration issue (seen Si vous avez besoin d'aide, contactez votre support. Merci de leur transmettre les informations contenues sur <a href=http://aide.aphp.fr>la page d'aide</a>.).

QuentinBibas commented 6 years ago

nah, backend is ok, it's just that i didn't give any parameters to the GET command.

and as i said, environement.dev.ts was created and edited with version= dev

~/pialab# cat src/environments/environment.dev.ts
export const environment = {
  name: 'production',
  production: true,
  version: 'dev',
  rollbar_key: ''
};
PapsOu commented 6 years ago

Please compare the content of your file with this content : https://github.com/pia-lab/pialab/blob/master/src/environments/environment.ts#L12

You will see that, as the error shown, the node api is missing in environment object.

So your environment.dev.ts should have this content :

export const environment = {
  name: 'production',
  production: true,
  version: 'dev',
  rollbar_key: '',
  api {
    client_id: 'THE CLIENT ID PICKED FROM PIALAB BACKEND',
    client_secret: 'THE SECRET PICKED FROM PIALAB BACKEND',
    host:          'THE HOST/URL OF THE PIALAB BACKEND',
    token_path:    '/oauth/v2/token'
  }
};
PapsOu commented 6 years ago

@QuentinBibas : Is the front is working now ?

[Edit] For the moment, the master branch works only if the authenticated user has role ROLE_ADMIN. The master branch is not stable at this point and will have a new tag soon when roles and permissions will be stabilized.

QuentinBibas commented 6 years ago

i'm giving up on PIA altogether. I've tried setting it up either with the main PIA branch or this one for 2 weeks now, nothing works. the law passes tomorrow, but none of the tools are ready in any shape of form, it's a nice disaster on CNIL's part.

anyways, what i've come to : back end works i've set it to 127.0.0.1 as localhost tries to go throught the corp proxy

~/pialab# GET http://localhost:8000
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="icon" type="image/png" href="/assets/img/favicon.png" />
        <title>
            PIA User Management        </title>

                    <link rel="stylesheet" href="/assets/css/semantic-superhero.min.css"/>
            <link rel="stylesheet" href="/assets/css/styles.css"/>

        <script src="/assets/js/jquery.min.js"></script>     </head>
    <body >

                <div class="ui middle aligned center aligned grid">
    <div class="column" style="transform: translateY(75%); max-width:400px">
        <h2 class="ui image">
            <img src="/assets/img/pia-lab.png" class="image">
        </h2>

        <form class="ui large form" action="/login_check" method="post">
            <div class="ui stacked segment">
                <div class="field">
                    <div class="ui left icon input">
                        <i class="user icon"></i>
                        <input type="text" name="_username" placeholder="E-mail address">
                    </div>
                </div>
                <div class="field">
                    <div class="ui left icon input">
                        <i class="lock icon"></i>
                        <input type="password" name="_password" placeholder="Password">
                    </div>
                </div>
                                    <input type="hidden" name="_csrf_token" value="IVfzsrbkQ7MiA81CZm6QH1XR9FzvZjASGX3Ub_L33-Y"/>

                <input type="checkbox" id="remember_me" name="_remember_me" value="on" />
                <label for="remember_me">Rester connecté</label>

                <button type="submit" name="_submit" class="ui fluid large blue submit button" onclick="this.closest('form').submit()">Login</button>
            </div>
        </form>
    </div>
</div>
root@pia-lab-00:~/pialab# cat src/environments/environment.prod.ts
export const environment = {
  name: 'production',
  production: true,
  version: '1.6.0',
  rollbar_key: ''
  api {
    client_id: '1_2m2ef8riatkwwww0wcwo4888ogsk84wwks4so0scc8ggkg4wkw',
    client_secret: '35tpnu29c46ckss008k4w0o8wgkg4wcsc48swoskskoc88kgcc',
    host:          '127.0.0.1:8000',
    token_path:    '/oauth/v2/token'
  }
};

ng build --prod still bugs at the same exact step, being "chunk assets processing"

/pialab# ng build --prod
Your global Angular CLI version (6.0.3) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".

@angular/compiler-cli@4.4.7 requires typescript@'>=2.1.0 <2.4.0' but 2.4.2 was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.

Please run the following command to install a compatible version of TypeScript.

    npm install typescript@'>=2.1.0 <2.4.0'

To disable this warning run "ng set warnings.typescriptMismatch=false".

Date: 2018-05-24T14:48:04.868Z                                                            
Hash: 1c02d41af4acc076d98c
Time: 33112ms
chunk {scripts} scripts.42df424e76703f0201d1.bundle.js (scripts) 519 kB [initial] [rendered]
chunk {0} polyfills.2b58010b88d06a3c15b2.bundle.js (polyfills) 64.8 kB [initial] [rendered]
chunk {1} main.9354336ad133f9ead4e6.bundle.js (main) 877 kB [initial] [rendered]
chunk {2} styles.a5aa95cf43297294488d.bundle.css (styles) 106 kB [initial] [rendered]
chunk {3} vendor.0652e3f966bfc5d7820c.bundle.js (vendor) 1.62 MB [initial] [rendered]
chunk {4} inline.31e1fb380eb7cf3d75b1.bundle.js (inline) 798 bytes [entry] [rendered]

ERROR in /root/pialab/src/environments/environment.ts (6,3): ',' expected.
ERROR in /root/pialab/src/environments/environment.ts (6,7): ':' expected.
ERROR in /root/pialab/src/app/services/authentication.service.ts (14,45): Property 'date_format' does not exist on type '{ name: string; production: boolean; version: string; rollbar_key: string; api: { client_id: stri...'.
ERROR in /root/pialab/src/environments/environment.prod.ts (6,3): ',' expected.
ERROR in /root/pialab/src/environments/environment.prod.ts (6,7): ':' expected.
PapsOu commented 6 years ago

The application is still under development.

So there are remaining bugs. But, in that case, you should check json/javascript/typescript syntax with a basic linter.

Your file is wrong, you're missing a colon in src/environments/environment.ts line 6 after rollbar_key: ''.

You're missing the key date_format too.

So this is only a configuration problem and a partial copy paste.

Please pay attention about errors messages that are pretty explicit :

ERROR in /root/pialab/src/environments/environment.ts (6,3): ',' expected.
ERROR in /root/pialab/src/environments/environment.ts (6,7): ':' expected.
ERROR in /root/pialab/src/app/services/authentication.service.ts (14,45): Property 'date_format' does not exist on type '{ name: string; production: boolean; version: string; rollbar_key: string; api: { client_id: stri...'.
ERROR in /root/pialab/src/environments/environment.prod.ts (6,3): ',' expected.
ERROR in /root/pialab/src/environments/environment.prod.ts (6,7): ':' expected.