【问题标题】:How to install node-sass without root and problems如何在没有 root 和问题的情况下安装 node-sass
【发布时间】:2019-01-29 00:23:39
【问题描述】:

我有很多关于 node-sass 的问题。我讨厌 node-sass,因为我无法安装所有东西。我无法安装 ionic4 或 nativescript。

我遇到了一些类似以下的错误:

configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/torbengab/Desktop/Projects/HelloNativeScript/my-tab-ng/node_modules/node-sass/build'
gyp ERR! System Darwin 17.3.0
gyp ERR! command "/usr/local/bin/node" "/Users/...../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/...../node_modules/node-sass
gyp ERR! node -v v10.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

Build failed with error code: 1
npm WARN extract-text-webpack-plugin@3.0.2 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.9.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我认为这是一个 root / sudo 问题。我试图卸载 node、npm、sass ......但我很愚蠢。没有什么对我有用。

我真的很希望有人可以帮助我。我对 sass 有这么多问题,真是令人难过和尴尬。

【问题讨论】:

    标签: node.js sass node-modules sudo node-sass


    【解决方案1】:

    更新最新的node-sass

    npm install node-sass@latest
    

    【讨论】:

      【解决方案2】:
      sudo npm install --unsafe-perm node-sass
      

      【讨论】:

        【解决方案3】:

        看起来您可能已以 root 身份安装(部分)您的项目,可能部分使用 sudo,部分以普通用户身份安装。

        首先以 root 身份删除项目的整个 node_modules 目录:

        sudo rm -fr /Users/torbengab/Desktop/Projects/HelloNativeScript/my-tab-ng/node_modules/
        

        (这假设您有一个正确的package.json,您可以使用它来重新安装项目的所有依赖项)

        接下来,使用项目目录中的npm install 重新安装。如果遇到问题,请不要使用sudo,希望能解决问题;相反,请阅读错误消息并尝试确定确切可能是问题的原因。如果您无法解决,请搜索或询问 StackOverflow。

        FWIW,在我的 Mac 上安装 node-sass 工作正常,所以这不是该软件包的固有问题。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-08-15
          • 2013-05-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多