Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SailsJS 0.11: ENOENT: no such file or directory, stat '.../node_modules/.bin/cdl'

Theres this SailsJS application that works on my office machine but not locally, I wonder why? Locally I run linux. In office Mac. Locally I get

Error: ENOENT: no such file or directory, stat '/home/jiewmeng/Dropbox/meclub/node_modules/.bin/cdl' at Error (native) at Object.fs.statSync (fs.js:849:18) at /home/jiewmeng/Dropbox/meclub/node_modules/include-all/index.js:44:12 at Array.forEach (native) at requireAll (/home/jiewmeng/Dropbox/meclub/node_modules/include-all/index.js:40:9) at /home/jiewmeng/Dropbox/meclub/node_modules/include-all/index.js:50:23 at Array.forEach (native) at requireAll (/home/jiewmeng/Dropbox/meclub/node_modules/include-all/index.js:40:9) at buildDictionary (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14) at Function.module.exports.optional (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/sails-build-dictionary/index.js:160:9) at Array.async.auto.nodeModulesFolder (/home/jiewmeng/Dropbox/meclub/node_modules/sails/lib/hooks/moduleloader/index.js:379:27) at /home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:484:38 at _each (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:46:13) at Object.async.auto (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:455:9) at Hook.loadUserHooks (/home/jiewmeng/Dropbox/meclub/node_modules/sails/lib/hooks/moduleloader/index.js:363:13) at Hook.bound [as loadUserHooks] (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21) at Hook.initialize (/home/jiewmeng/Dropbox/meclub/node_modules/sails/lib/hooks/userhooks/index.js:29:18) at Hook.bound [as initialize] (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21) at /home/jiewmeng/Dropbox/meclub/node_modules/sails/lib/hooks/index.js:75:14 at /home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:451:17 at /home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:441:17 at _each (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:46:13) at Immediate.taskComplete (/home/jiewmeng/Dropbox/meclub/node_modules/sails/node_modules/async/lib/async.js:440:13) at processImmediate [as _immediateCallback] (timers.js:374:17)

I am using Sails 0.11. Server can actually start with Sails 0.12 but theres some breaking changes, thus I am stuck with 0.11 for now. I am using Node 4.

like image 638
Jiew Meng Avatar asked Apr 21 '16 15:04

Jiew Meng


4 Answers

I think you are using dropbox to sync office laptop with your machine, due to which some files are getting added into your project which will not cause problem in one OS but can create the issue in other.

Thus, I suggest that you should follow the standard practices to clone the project

  1. Use the git or bitbucket to clone the project.
  2. install the dependencies => npm install

Don't use dropbox for the project sync. Use the version control system to clone/pull the code, and install all dependencies

because node-gyp compiles native add-on modules for Node.js with respect to OS

and hopefully, after this it should work fine.

If you don't want to use the VCS then you can follow the below steps:

 # cd /home/jiewmeng/Dropbox/meclub
 # sudo rm -rf node_modules
 # rm -rf ~/.npm
 # npm cache clear
 # npm install

That's all you need to do.

like image 180
Vishnu Mishra Avatar answered Nov 22 '22 05:11

Vishnu Mishra


You don't have to delete the whole node_modules directory. Just run npm rebuild and it will rebuild modules if they don't match your current architecture.

like image 44
alsdkjasdlkja Avatar answered Nov 22 '22 06:11

alsdkjasdlkja


You need to rebuild your node_modules if you are moving to a new machine. You can do it like this:

cd /home/jiewmeng/Dropbox/meclub
rm -rf node_modules
npm install

The reason why this is required is that the .bin folder is full of symlinks. This will likely cause issues with Dropbox. Also, resources in the .bin folder are sometimes compiled natively. Moving from Ubuntu to Mac OSX without recompiling, will be an issue at runtime for many components.

Just as with a VCS, I would recommend that you do not sync the node_modules folder at all. This should not be shared between machines. You can manage these dependencies using NPM on each computer.

like image 31
Kevin Burdett Avatar answered Nov 22 '22 05:11

Kevin Burdett


  1. Make sure you are running Sails from the correct directory, using sails lift or whatever you use
  2. Do a npm install to make sure all the modules are installed
  3. Manually check if all modules in package.json are available in your node_modules folder
  4. Make sure the versions of the Node is same in both (it shouldn't be a problem even if not - in most cases)
  5. Try re-installing sails and node in the worst case.
like image 23
Abdul Vajid Avatar answered Nov 22 '22 05:11

Abdul Vajid