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

4.3k views Asked by At

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.

1

There are 1 answers

1
koko-js478 On BEST ANSWER

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