Node JS在Amazon Linux中作为普通用户运行时无法找到模块'node-properties-parser'错误

问题描述 投票:0回答:1

我通过运行node-properties-parser作为普通用户(vaisakh)在全球安装了npm install -g node-properties-parser。然后我用命令test.js运行我的node test.js文件,现在它正在抛出错误

Error: Cannot find module 'node-properties-parser'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/data02/bamboo/test.js:3:12)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)

我以root用户身份运行上面的npm install -g node-properties-parser并在这里运行node test.js它工作正常。但是为什么它在以普通用户身份运行时抛出错误?

javascript node.js linux node-modules amazon-linux
1个回答
0
投票

谢谢。最后我找到了答案,它在没有sudo npm install node-properties-parser选项的情况下运行-g时工作。但我仍然不知道为什么-g选项不是woking,在它作为install globally给出的文档中。

© www.soinside.com 2019 - 2024. All rights reserved.