packagenpmlivescript

Can I execute two Livescript (Coffeescript-fork) applications with single globally installed package?


I am running an application that is built with LiveScript, which is a fork of a fork of Coffeescript.

You can execute files using the lsc command, ie

$ lsc app.ls

However, in the recent update, the way modules are required changes, ie

require!{ module : \directory }

Has now become

require!{ \directory : module}

This leaks to breaking changes in my app. I have updated the globally installed LiveScript package to 1.3+, and updated the require syntax, but now when I try and run an old app with the old require syntax the app breaks and I need to reinstall the globally installed LiveScript package to get it to work.

Is there anyway to run version <= 1.2 modules and 1.3+ modules from the same command line? Or do I need to reinstall the package globally everytime?


Solution

  • I can only suggest to not use global installation. It's quite bad by itself, and definitely not usable in this case.

    I will show you how to install and use multiple versions of LiveScript isolated in a folder.

    [ls]$ mkdir old_version && cd old_version
    
    [old_version]$ npm view LiveScript versions  
    
    ['0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5-b', '0.9.5-c', '0.9.5', '0.9.6', '0.9.7', '0.9.8-b', '0.9.8-c', '0.9.8', '0.9.9', '0.9.10', '0.9.11-b', '0.9.11', '0.9.12', '1.0.0', '1.0.1', '1.1.0', '1.1.1', '1.2.0', '1.3.0', '1.3.1']
    
    [old_version]$ npm install LiveScript@1.2.0
    LiveScript@1.2.0 node_modules/LiveScript
    └── prelude-ls@1.0.3
    
    [old_version]$ cd ..
    
    [ls]$ mkdir new_version && cd new_version
    
    [new_version]$ npm install LiveScript
    LiveScript@1.3.1 node_modules/LiveScript
    ├── prelude-ls@1.1.1
    └── optionator@0.4.0 (type-check@0.3.1, deep-is@0.1.3, levn@0.2.5, wordwrap@0.0.2, fast-levenshtein@1.0.4)
    
    [new_version]$ cd ..
    
    [ls]$ old_version/node_modules/.bin/lsc
    LiveScript 1.2.0 - use 'lsc --help' for more information
    ls> 
    
    [ls]$ new_version/node_modules/.bin/lsc
    LiveScript 1.3.1 - use 'lsc --help' for more information
    ls> 
    
    [ls]$ tree -a -L 4
    .
    ├── new_version
    │   └── node_modules
    │       ├── .bin
    │       │   └── lsc -> ../LiveScript/bin/lsc
    │       └── LiveScript
    │           ├── bin
    │           ├── lib
    │           ├── LICENSE
    │           ├── node_modules
    │           ├── package.json
    │           └── README.md
    └── old_version
        └── node_modules
            ├── .bin
            │   ├── livescript -> ../LiveScript/bin/livescript
            │   ├── lsc -> ../LiveScript/bin/lsc
            │   └── slake -> ../LiveScript/bin/slake
            └── LiveScript
                ├── bin
                ├── lib
                ├── LICENSE
                ├── node_modules
                ├── package.json
                └── README.md
    

    It should be possible to have one version installed globally and one like this, too.