Less.js: 3.11.0 Cannot find module 'tslib'

Created on 10 Feb 2020  ·  19Comments  ·  Source: less/less.js

Cannot find module 'tslib' 3.11.0

high priority

Most helpful comment

3.11.0 was such a big update.
Should have been 4.0.0

All 19 comments

I can acknowledge the problem. It came up with the newest version, 3.10.3 worked fine. Maybe @matthew-dean could check the last merge?

Steps to reproduce with docker

  1. create a new folder
  2. place some test.lesscontaining valid less code there
  3. create a Dockerfile with following content:
FROM buildpack-deps:buster

COPY test.less /

# install npm
ENV HOME /root
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs

# install less and compile something
RUN npm install -g less
WORKDIR /
RUN lessc test.less test.css
  1. Call docker build . in the folder

This will cause the following error:

Step 6/8 : RUN npm install -g less
 ---> Running in a76855c18efa
/usr/bin/lessc -> /usr/lib/node_modules/less/bin/lessc
+ [email protected]
added 60 packages from 123 contributors in 4.306s
Removing intermediate container a76855c18efa
 ---> b78508030649
Step 7/8 : WORKDIR /
 ---> Running in 6cca70d0d858
Removing intermediate container 6cca70d0d858
 ---> d812408c6ef8
Step 8/8 : RUN lessc test.less test.css
 ---> Running in 6c8ef5fc9408
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'tslib'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/lib/node_modules/less/bin/lessc:9:13)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
The command '/bin/sh -c lessc test.less test.css' returned a non-zero code: 1

Also reproducible with grunt-contrib-less ("grunt-contrib-less": "2.0.0") which uses "less": "^3.0.4".
A gulp issue was reported too.

3.11.0 was such a big update.
Should have been 4.0.0

Also triggered errors on the Yarn E2E testsuite (we use that to monitor various projects):
https://github.com/yarnpkg/berry/runs/436357016

I suspect the project just needs to add a dependency to tslib - people tend to forget to explicitly list it because the source files don't reference it, only the build artifacts do.

Well shoot, sorry all. The build was passing unit tests, so I guess there was a missing test here.

@siimots

3.11.0 was such a big update. Should have been 4.0.0

Not really, in terms of semver. There should be no backwards-incompatible changes, just changes to some build settings. I'll check it out shortly.

@arcanis

I suspect the project just needs to add a dependency to tslib - people tend to forget to explicitly list it because the source files don't reference it, only the build artifacts do.

Probably the reason this happened is because tslib might be an implicit dependency (dependency of a dependency) in the devDependencies. So tests would pass but a normal npm install wouldn't install it.

+1, also seeing this with apostrophecms. Looks like this will be getting fixed quickly, thank you.

As an aside, if anyone knows of a reliable method to simulate / test a library install as a dependency and run tests without the need to wipe / reinstall node modules, I'd love to hear it.

@matthew-dean Fwiw this kind of issue is one of the reasons we introduced Plug'n'Play in Yarn. It throws exceptions when packages make unsafe accesses (such as tslib here) instead of letting them mistakenly succeed. Of course it requires to use Yarn since npm doesn't support it, so it may not be what you're looking for 🙂

To give you an example, this is what the test I linked reported:

image

Can someone verify that this build is fixing things? https://github.com/less/less.js/tree/release-3.11.1

You can have node_modules folders nested anywhere. So you can put one in
your test/ folder that is only used for this purpose and is more convenient
to blow up. We do this with apostrophe.

On Mon, Feb 10, 2020 at 4:37 PM Matthew Dean notifications@github.com
wrote:

Can someone verify that this build is fixing things?
https://github.com/less/less.js/tree/release-3.11.1


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/less/less.js/issues/3469?email_source=notifications&email_token=AAAH27IM5UVBLOEMPE5BJR3RCHCJBA5CNFSM4KSHHJ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELKMI5A#issuecomment-584369268,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAH27OZWO622K5JYHEYNCLRCHCJBANCNFSM4KSHHJ6Q
.

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his

Inside that you can have a symlink to find the main folder of the module by
the right name.

On Mon, Feb 10, 2020 at 5:02 PM Tom Boutell tom@apostrophecms.com wrote:

You can have node_modules folders nested anywhere. So you can put one in
your test/ folder that is only used for this purpose and is more convenient
to blow up. We do this with apostrophe.

On Mon, Feb 10, 2020 at 4:37 PM Matthew Dean notifications@github.com
wrote:

Can someone verify that this build is fixing things?
https://github.com/less/less.js/tree/release-3.11.1


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/less/less.js/issues/3469?email_source=notifications&email_token=AAAH27IM5UVBLOEMPE5BJR3RCHCJBA5CNFSM4KSHHJ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELKMI5A#issuecomment-584369268,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAH27OZWO622K5JYHEYNCLRCHCJBANCNFSM4KSHHJ6Q
.

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his

@matthew-dean ... how can i change my package.json file to try out your new release? I still am only able to pull down 3.11.0 if I don't specify a version.

@boutell That's not the most clear description. Do you mean setting up some sort of sub-package in the repo? I'm wondering how you do this in a way that won't encounter Node's parent node_modules resolution algorithm.

@jmwolfe

https://docs.npmjs.com/files/package.json#git-urls-as-dependencies

Hmm. No, you're right, that doesn't quite suit your situation. The only
sure thing I can think of would be setting up a local npm proxy in which
that particular module is satisfied from your own location, and testing npm
install against that. Local npm proxies like this are actually not hard to
come by but it is kind of a lot.

On Mon, Feb 10, 2020 at 5:10 PM Matthew Dean notifications@github.com
wrote:

@boutell https://github.com/boutell That's not the most clear
description. Do you mean setting up some sort of sub-package in the repo?
I'm wondering how you do this in a way that won't encounter Node's parent
node_modules resolution algorithm.

@jmwolfe https://github.com/jmwolfe

https://docs.npmjs.com/files/package.json#git-urls-as-dependencies


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/less/less.js/issues/3469?email_source=notifications&email_token=AAAH27O3T4O2Z7VPTBA6HYLRCHGEPA5CNFSM4KSHHJ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELKPPYQ#issuecomment-584382434,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAH27JP6LEUZIENWBEWERLRCHGEPANCNFSM4KSHHJ6Q
.

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his

@matthew-dean - using this in my package.json works to fix gulp-less which depends on less:

"dependencies": {
    "less": "git://github.com/less/less.js.git#afc9b86"
}

# npm list less
[email protected] C:\SVN\CMGR\branches\cmgr_pmm2\ContentManager\ContentManager            
+-- [email protected]                                                                           
| `-- [email protected]  deduped (git://github.com/less/less.js.git#afc9b8606272a01bf4392f71e4d9db59d06fddb9)                                                                                     
`-- [email protected]  (git://github.com/less/less.js.git#afc9b8606272a01bf4392f71e4d9db59d06fddb9)

my resulting gulpfile.js loads perfectly.

ps. gulp-less and a few other packages are in devDependencies.

Great, thank you! Is this published to npm?

On Tue, Feb 11, 2020 at 12:53 AM Matthew Dean notifications@github.com
wrote:

Closed #3469 https://github.com/less/less.js/issues/3469 via 842386b
https://github.com/less/less.js/commit/842386b8db5cb5afa4edf5a4c81d40bcbf47a6a2
.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/less/less.js/issues/3469?email_source=notifications&email_token=AAAH27NPPJXO4IOUM2I2J3LRCI4NLA5CNFSM4KSHHJ62YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWRJHA5I#event-3025301621,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAH27I5LOTWY22VMC57QFLRCI4NLANCNFSM4KSHHJ6Q
.

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his

@boutell yes it is. I just verified.

👍 thanks for all you do!

On Tue, Feb 11, 2020 at 12:18 PM Jesse Wolfe notifications@github.com
wrote:

@boutell https://github.com/boutell yes it is. I just verified.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/less/less.js/issues/3469?email_source=notifications&email_token=AAAH27P3RR4ZWL6PXZHC7N3RCLMXRA5CNFSM4KSHHJ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELNIUHY#issuecomment-584747551,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAH27MKPLJTLBZ5NLHZWALRCLMXRANCNFSM4KSHHJ6Q
.

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his

Was this page helpful?
0 / 5 - 0 ratings