docker-mastery-for-nodejs | Docker Mastery for Node.js Projects , From a Docker Captain | Continuous Deployment library
kandi X-RAY | docker-mastery-for-nodejs Summary
kandi X-RAY | docker-mastery-for-nodejs Summary
Docker Mastery for Node.js Projects, From a Docker Captain
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of docker-mastery-for-nodejs
docker-mastery-for-nodejs Key Features
docker-mastery-for-nodejs Examples and Code Snippets
Community Discussions
Trending Discussions on docker-mastery-for-nodejs
QUESTION
When building an image that needs to be compiled from typescript, I get this error.
sh: 1: tsc: not found
The command '/bin/sh -c npm run tsc' returned a non-zero code: 127
Here is the relevant code:
docker-compose.yaml
...ANSWER
Answered 2021-Apr-22 at 21:38Use npm ci
(or add package-lock.json
to your .dockerignore
file, or delete package-lock.json
in your local environment before building). The why is answered here.
EDIT:
Here's what I believe is going on. Disclaimer, I'm not an expert on nodejs
or npm
-- in fact I'm something of a novice. And all of this is conjecture based on some experiments.
npm
is not linking the binaries for the dev dependencies via sym links in node_modules/.bin
because the package-lock.json
file has gotten into a corrupted state where the (prod) dependencies are in lockfileVersion 2 format, and the dev dependencies are still in lockfileVersion 1 format.
Note: Making a bunch of assumptions here.
Your local host using using npm 6, and the docker container is using npm 7. Because of this, the existing
package-lock.json
is inlockfileVersion: 1
which doesn't include abin
section for dependencies that have binaries. Version 2 does save thebin:
section, whichnpm
must use to determine what binaries to install/link.When you run the production dependency install (e.g.
NODE_ENV=production npm install
), usingnpm
version 7,npm
is upgrading the version of yourpackage-lock.json
tolockfileVersion: 2
, part of this includes savingbin:
sections for the dependencies that install binaries. Importantly, it updates only the production dependencies. Now thepackage-lock.json
file is corrupted because it claims to be in version 2 format, but all the dev dependencies are either still in version 1 or at least don't have thebin:
section correctly applied.When you now try to install your dev dependencies,
npm
sees that thepackage-lock.json
is inlockfileVersion: 2
, so it assumes that the dev dependencies have been upgraded as well (but they haven't been, or at least not correctly). It doesn't find thebin:
sections because they don't exist and so it doesn't link the binaries to thenode_modules/.bin/
directory.
You can perform a minimum reproduction of it using this Dockerfile
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install docker-mastery-for-nodejs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page