1

我正在运行一个使用 LiveScript 构建的应用程序,它是 Coffeescript 的一个分支。

您可以使用 lsc 命令执行文件,即

$ lsc app.ls

但是,在最近的更新中,模块所需的方式发生了变化,即

require!{ module : \directory }

现在变成了

require!{ \directory : module}

这泄漏到我的应用程序中的重大更改。我已将全局安装的 LiveScript 包更新到 1.3+,并更新了 require 语法,但是现在当我尝试使用旧的 require 语法运行旧应用程序时,应用程序会中断,我需要重新安装全局安装的 LiveScript 包才能让它工作。

无论如何从同一命令行运行版本 <= 1.2 模块和 1.3+ 模块?还是我每次都需要在全球范围内重新安装软件包?

4

1 回答 1

2

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.

于 2014-11-29T09:12:12.397 回答