~/Desktop/editify$ sudo -s
root@kritidipto-HP-Laptop-15-bs0xx:/home/kritidipto/Desktop/editify# grunt run
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'liftoff'
Require stack:
- /usr/share/nodejs/grunt-cli/bin/grunt
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/share/nodejs/grunt-cli/bin/grunt:7:15)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/share/nodejs/grunt-cli/bin/grunt' ]
}
Grunt 似乎在 sudo 模式下无法工作,但在我非 root 时可以工作。我需要使用 root 用户运行 grunt 命令,因为它将执行需要权限的操作。
grunt-cli v1.4.3
grunt v0.4.5
node v10.16.0
npm 6.9.0
我也使用 nvm 在 npm 的多个版本之间切换。