美文网首页
解决 Error: Cannot find module '/r

解决 Error: Cannot find module '/r

作者: Rami | 来源:发表于2022-12-13 14:01 被阅读0次

    linux下通过jenkins安装vue项目依赖,出现如下报错:

    > yorkie@2.0.0 install /root/.jenkins/workspace/你的项目路径/node_modules/yorkie
    > node bin/install.js
    
    internal/modules/cjs/loader.js:892
      throw err;
      ^
    
    Error: Cannot find module '/root/.jenkins/workspace/你的项目路径/node_modules/yorkie/bin/install.js'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
        at Function.Module._load (internal/modules/cjs/loader.js:745:27)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
        at internal/main/run_main_module.js:17:47 {
      code: 'MODULE_NOT_FOUND',
      requireStack: []
    }
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    
    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 ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2022-12-14T03_48_06_801Z-debug.log
    pd:extension is failed
    Build step 'Execute shell' marked build as failure
    Finished: FAILURE
    

    原因

    npm 出于安全考虑不支持以 root 用户运行,即使你用 root 用户身份运行了,npm 会自动转成一个叫 nobody 的用户来运行,而这个用户几乎没有任何权限。这样的话如果你脚本里有一些需要权限的操作,比如写文件(尤其是写 /root/.node-gyp),yorkie就需要写文件,然后就崩掉了。说白了就是权限不足

    解决

    方案一:先执行 npm install @vue/cli-service --unsafe-perm,再执行npm i;或者直接执行 npm install --unsafe-perm(常用)

    方案二:修改项目的目录权限为777

    相关文章

      网友评论

          本文标题:解决 Error: Cannot find module '/r

          本文链接:https://www.haomeiwen.com/subject/qkuhqdtx.html