2012-01-14 21 views
25

Come si installa JSLint su Ubuntu?Come installo JSLint su Ubuntu?

Ho scaricato la sorgente jsl-0.3.0-src.tar.gz da http://www.javascriptlint.com/download.htm e quindi l'ho estratta in una directory chiamata jsl-0.3.0 sul mio desktop. L'ho quindi spostato a /usr/local/bin che I have read is my PATH. Voglio anche ricordare che ho già installato Rhino 1.7.

Quando provo a fare funzionare jsl dal terminale ho ricevuto il seguente messaggio:

No command 'jsl' found, did you mean: 
Command 'jls' from package 'sleuthkit' (universe) 
Command 'js' from package 'rhino' (main) 
Command 'sl' from package 'sl' (universe) 
Command 'fsl' from package 'fsl' (multiverse) 
jsl: command not found 

Così come posso correttamente installare JSLint?

+7

Chiuso come fuori tema? Davvero, chi altro userà JSLint? – boatcoder

+0

Ironia della sorte, non è nella maggior parte dei gestori di pacchetti perché "Il software deve essere usato per il bene, non per il male". - che presumibilmente non rende "open source". – NoBugs

+0

@NoBugs: puoi usare [JSHint] (https://github.com/jshint/jshint/blob/master/LICENSE) –

risposta

19

Here sono le istruzioni che ho seguito per far funzionare jslint su Ubuntu 10.10/Vim 7.3 (e Mac OS X).

EDIT

Così, ho appena notato un errore nel link indicato. Questi sono i passi corretti (ammesso che abbiate già scaricato e scompattato l'archivio sul desktop:

$ cd /path/to/jsl-0.3.0/src 
$ make -f Makefile.ref 
$ cp Linux_All_DBG.OBJ/jsl /usr/local/bin/jsl 

A quel punto si può aprire una nuova finestra di terminale e digitare $ jsl per visualizzare un aiuto rapido o invocare da Vim o direttamente su un file nel terminale.

FINE EDIT

  • /usr/local/bin non è il vostro "percorso", è solo uno dei molti indici che possono essere parte la variabile PATH ambiente. $ echo $PATH ti dirà quali sono queste directory e quindi dove puoi mettere l'eseguibile jsl. Puoi anche metterlo in un altro posto e aggiungere un alias al tuo .bashrc.

  • Perché prevedete di essere in grado di eseguire jslint da rhino?

+0

quando faccio 'echo $ PATH' vedo un elenco di percorsi separati da due punti. '/ usr/local/bin' è tra questi.Quindi quello che ho fatto è stato creare una directory 'jsl' in'/usr/local/bin/'e quindi rilasciare l'intera cartella' jsl-0.3.0' che contiene 'jsl'. Quindi l'intero percorso di 'jsl' è'/usr/local/bin/jsl/jsl-0.3.0/src/Linux_All_DBG.OBJ'. Quando digito 'jsl' ottengo lo stesso errore' jsl: comando non trovato' di cui ho parlato nel mio post. grazie ancora finora –

+0

Devi ** costruire ** 'jsl' prima e _ poi rendere l'eseguibile risultante accessibile a livello di sistema. C'è un errore lì, però. Modificherò la mia risposta. – romainl

2

Hai detto che hai appena copiato l'origine in/usr/local/bin. Hai bisogno di compilarlo. Segui le istruzioni di costruzione nel README.html

Unix

  • Use 'gmake -f Makefile.ref' to build. To compile optimized code, pass BUILD_OPT=1 on the gmake command line or preset it in the environment or Makefile.ref. NOTE: Do not attempt to use Makefile to build the standalone JavaScript engine. This file is used only for building the JS-engine in the Mozilla browser.
  • Each platform on which JS is built must have a *.mk configuration file in the js/src/config directory. The configuration file specifies the compiler/linker to be used and allows for customization of command-line options. To date, the build system has been tested on Solaris, AIX, HP/UX, OSF, IRIX, x86 Linux and Windows NT.
  • Most platforms will work with either the vendor compiler or gcc. (Except that HP builds only work using the native compiler. gcc won't link correctly with shared libraries on that platform. If someone knows a way to fix this, let us know.)
  • If you define JS_LIVECONNECT, gmake will descend into the liveconnect directory and build LiveConnect after building the JS engine.
  • To build a binary drop (a zip'ed up file of headers, libraries, binaries), check out mozilla/config and mozilla/nsprpub/config. Use 'gmake -f Makefile.ref nsinstall-target all export ship'

Per quanto riguarda la tua domanda sulla differenza. Dice sulla pagina di download che uno è scritto in JavaScript stesso.

We all stand on the shoulders of giants. I would like to especially acknowledge Douglas > Crockford's work on JSLint. This lint is itself written in JavaScript and is an interesting and rather sophisticated script. Crockford's ideas about good coding practices served as a springboard for many of these lint rules.

+0

Ubuntu non ha 'gmake' quindi ho usato' make', che è la stessa cosa. Si è concluso senza errori, quindi presumo che sia stato costruito bene, ma non riesco ancora a eseguire JSLint digitando il comando 'jsl' nel terminale o eseguendo' rhino' (o 'js') e digitando' jslint'. Se provo quest'ultimo, ricevo 'Errore:" jslint "non è definito. –

+0

In genere, è necessario digitare 'make install' in seguito per copiare i file binari e necessari nella directory bin. Digitando 'make' produci un file binario' jsl' nella directory dei sorgenti? –

+0

dopo aver fatto 'make -f Makefile.ref' è stata creata una dir chiamata' Linux_All_DBG.OBJ' che conteneva un file chiamato 'jsl' e un altro chiamato' jsl.o' che erano tra molti altri file. Inoltre, 'make install' non ha funzionato nelle directory' src' o 'Linux_All_DBG.OBJ'. Ho ottenuto l'errore 'make: *** Nessuna regola per rendere la destinazione' install '. Stop –

1

Guarda il tuo file "jsl-0.3.0/src/README.html". Questo dice:

1) Si dispone di un "pacchetto sorgente". Devi "costruirlo" (con un compilatore C), quindi installare la tua build.

2) Questo è più di un semplice JSLint. È un intero motore Javascript. Per il README:

This is the README file for the JavaScript Reference (JSRef, now better known as SpiderMonkey) implementation. It consists of build conventions and instructions, source code conventions, a design walk-through, and a brief file-by-file description of the source.

JSRef builds a library or DLL containing the JavaScript runtime (compiler, interpreter, decompiler, garbage collector, atom manager, standard classes). It then compiles a small "shell" program and links that with the library to make an interpreter that can be used interactively and with test .js files to run scripts. The code has no dependencies on the rest of the Mozilla codebase.

3) Qui la pagina JSLint originale di Douglas Crockford:

http://www.jslint.com/

4) E qui è aa buon esempio di come si potrebbe utilizzare JSLint a livello locale, sul proprio PC :

http://code.google.com/p/js-ria-tools/wiki/JSLint

5) Tu dici che dispone già di Rhino - buono. In Google, troverai molti link obsoleti a www.jslint.com/rhino. Ecco perché - insieme con i link alle attuali informazioni Rhino correlati:

http://hustoknow.blogspot.com/2011/02/jslint-and-rhino-support.html

'Speranza che aiuta!

+0

Grazie. Ho costruito il sorgente tramite 'make -f Makefile.ref', che ha volato senza errori fino a quel momento, ma non posso ancora usare' jslint' quando si trova nell'interprete JS (che viene richiamato tramite 'js' o' rhino'). Anche l'esecuzione di 'jsl' non funziona ancora dal terminale. Qualche idea? –

57

Come installare JSLint su Ubuntu:

  1. Installare nodejs (include npm, il Nodo Package Manager):

    sudo apt-get install nodejs 
    
  2. Installare nodo-JSLint. sia a livello globale:

    sudo npm install -g jslint 
    

    o localmente, e comprendono in $PATH:

    npm install jslint 
    

    e aggiungere questa linea al vostro .bashrc (regolare il numero di versione a seconda dei casi)

    alias jslint='~/.npm/jslint/0.1.8/package/bin/jslint.js' 
    
+0

questo è perfetto dato che attualmente sto imparando il nodo, ma quando ho fatto '$ npm install -g jslint' ho ricevuto un errore che ho postato nella mia domanda come AGGIORNAMENTO. L'uso di 'sudo' lo risolverà? –

+0

se si sta installando 'npm' usando questo comando:' sudo apt-get install npm'. Quindi è necessario utilizzare sudo: 'sudo npm install -g jslint' – gmunkhbaatarmn

+0

Sembra una soluzione semplice, ma quando eseguo l'installazione di npm, crea solo una cartella .node_module. Non riesco ancora a eseguire jslint nella shell. Come supponiamo di avere un file eseguibile? – FMaz008