在Linux系统中用npm install安装模块报错

/ Node.JS / 没有评论 / 1891浏览

在Linux系统中用npm install安装模块报错

做了一个Vue项目,部署上线,npm i下载相关模块报错

> yorkie@2.0.0 install /home/root/apps/config-manager/out/webapp/frontend/node_modules/yorkie
> node bin/install.js

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module '/home/root/apps/config-manager/out/webapp/frontend/node_modules/yorkie/bin/install.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yorkie@2.0.0 install: `node bin/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the yorkie@2.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

解决办法

npm install @vue/cli-service --unsafe-perm

原因

For security reasons, if you run npm install as root, npm will set the user to “nobody” when running postinstall scripts, which does not have access to the project directory, thus the error message.