尝试运行grunt时找不到模块“findup-sync”
我在安装后运行grunt-cli时遇到了麻烦。 我跑
npm install -g grunt-cli
然后运行grunt错误
node.js:63 throw e; ^ Error: Cannot find module 'findup-sync' at loadModule (node.js:275:15) at require (node.js:411:14) at Object.<anonymous> (/home/tmartin/bin/grunt:9:14) at Module._compile (node.js:462:23) at Module._loadScriptSync (node.js:469:10) at Module.loadSync (node.js:338:12) at Object.runMain (node.js:522:24) at Array.<anonymous> (node.js:756:12) at EventEmitter._tickCallback (node.js:55:22) at node.js:773:9
这是我所安装的:
tmartin@timcomp:~$ npm list -g /home/tmartin/lib └─┬ grunt-cli@0.1.6 ├─┬ findup-sync@0.1.2 │ ├─┬ glob@3.1.21 │ │ ├── graceful-fs@1.2.0 │ │ ├── inherits@1.0.0 │ │ └─┬ minimatch@0.2.11 │ │ ├── lru-cache@2.2.2 │ │ └── sigmund@1.0.0 │ └── lodash@1.0.1 └─┬ nopt@1.0.10 └── abbrev@1.0.4
我不得不安装并链接findup-sync和一些其他的npm软件包,以使这些依赖性问题消失。 我虽然npm应该为我们处理,但手动安装依赖关系使问题消失。
npm install findup-sync -g
npm link findup-sync
我得到了我的运行再次重新安装grunt-cli全球和我的回购。
npm install -g grunt-cli
cd myrepo
npm install grunt-cli
我认为优胜美地的安装在我的文件中破坏了一些东西…
这是因为npm不会在/ usr / lib / node_modules / grunt-cli中为子目录node_modules设置正确的权限。 就我而言,我有:
drwxr-x--- 6 nobody root 4096 16 févr. 17:08 node_modules
以非root用户身份运行grunt时,由于拒绝读取此目录的权限,导致同样的错误(无法find模块“findup-sync”)。
解决scheme是使用chmod修复权限:chmod a + rx node_modules。
但事实上,所有的目录都涉及到了。 最好的办法是待办事项:
find /usr/lib/node_modules/grunt-cli -type d -exec chmod a+rx {} \;
这可能是一个分发bug(我使用Archlinux)。
这看起来很简单,但如果其他人不确定是否存在权限问题,请尝试运行sudo grunt
然后从那里开始。