Saturday, February 26, 2022

[SOLVED] Termux NodeJS - npm install fails, cannot create symbolic link. Workaround

Issue

Termux will not allow you to create symbolic links in /storage/emulated/0. This is due to a design limitation with its file system. Thus, some npm installs will fail with the following error:

    npm install js-yaml

    npm ERR! code EPERM                           
    npm ERR! syscall symlink                      
    npm ERR! path ../esprima/bin/esparse.js

Workaround #1:

Perform the npm install globally:

    npm install --global js-yaml

If your program won't run because it can't find the package:

    var yaml = require('js-yaml');

    Error: Cannot find module 'js-yaml'

Workaround #2:

Hard-code the full path in your program as such:

    var yaml = require('/data/data/com.termux/files/usr/lib/node_modules/js-yaml/lib/js-yaml.js');

Please comment.


Solution

Try this solution.

INSTALL GLOBAL NPM PACKAGES

npm config set unsafe-perm true

CLEAN CACHE

npm cache clean

BYPASS SYMLINK ISSUES

npm install --no-bin-links



Answered By - koko-js478
Answer Checked By - Mary Flores (WPSolving Volunteer)