npm install without symlinks option not working npm install without symlinks option not working node.js node.js

npm install without symlinks option not working


The NPM docs about parameter "--no-bin-links" say:

will prevent npm from creating symlinks for any binaries the package might contain.

Which will just cause NPM to not create links in the node_modules/.bin folder. I also searched for a way to prevent NPM from creating symlinks when using npm install ../myPackage, but can't find any solution...

Update: The npm support team said this will reproduce the old behaviour (no symbolic links):

npm install $(npm pack <folder> | tail -1)

Works for me in git-bash on Windows 10.


This Stack Overflow page comes up in Google search results when trying to solve the issue of installing local modules (ie. npm install ../myPackage) and not wanting symbolic links. So I'm adding this answer below to help others who end up here.

Solution #1 - For development environment.

Using the solution proposed by the NPM support team as mentioned in the other answer works...

# Reproduces the old behavior of hard copies and not symlinksnpm install $(npm pack <folder> | tail -1)

This is fine in the development environment for manual installs.

Solution #2 - For build environment.

However, in our case, the development environment doesn't quite matter as much though because when committing our changes to Git, the ./node_modules/ folder is ignored anyway.

The files ./package.json and ./package-lock.json is what is important and is carried into our build environment.

In our build environment (part of our automated CI/CD pipeline), the automation just runs the npm install command and builds from the dependencies listed in the package.json file.

So, here is where the problem affects us. The locally referenced files in the dependencies list of the package.json causes symlinks to appear. Now we are back to the old problem. These symlinks then get carried into the build's output which move onto the Stage and Production environments.

What we did instead is use rsync in archive mode with the --copy-links option that turns symbolic links into copies of the original.

Here is what the command looks like in the automated build:

# Install dependencies based on ./package.jsonnpm install# Make a copy that changes symlinks to hard copiesrsync --archive --verbose --copy-links ./node_modules/ ./node_modules_cp/# Remove and replacerm -r ./node_modules/mv ./node_modules_cp/ ./node_modules/


I have a similar environment. Apparently the Virtualbox (vagrant) synchronisation has problems when renaming or moving files, which happens when updating modules.

If you do a file listing (ls -alhp) on the command line and see ??? for the file permissions, then it is time to reboot your virtualbox. This will set the permissions to valid values. Then use the --no-bin-links option when installing a module.