'npm install doesn't install typescript (on mac)

I try to use typescript as a local dependency. What I want, is to have it checked into my devDependencies, and use it via an npm script, after npm install'ing it.

What I find is, that typescript (and webpack-cli for that matter as well) won't be installed if I try this on my machine.

Steps to reproduce (as a shell script):

mkdir myproject
cd myproject
npm init --yes
npm i --save-dev typescript

now, cat package.json will confirm, that typescript is checked into our devdependencies, but even after another npm install, the node_modules directory will remain completly empty.

What am I doing wrong here?

  • Node version: v16.14.2
  • npm version: 8.5.0
  • OS: macOs Monterey

(I previously encountered that this happens no matter which version I am using)

The Computer is freshly set up, only thing I did is log into a private npm repository

This seems to work fine in linux

running these steps inside linux (docker container with node image) will result in a different result: ls node_modules will show typescript

This also works fine on a coworkers mac

I am therefore a bit at loss about what is going on here

This also works fine on my machine, if not using zsh but bash.

I am using oh my zsh



Solution 1:[1]

I had NODE_ENV=production set as an env variable, coming from a rather buried env script.

not clever, but hard to find

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nils Martel