【问题标题】:Unable to create a new Ionic 3 project npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.5.3 postinstall: `node scripts/build.js`无法创建新的 Ionic 3 项目 npm ERR!代码 ELIFECYCLE npm 错误! errno 1 npm 错误! node-sass@4.5.3 安装后:`node scripts/build.js`
【发布时间】:2019-06-20 04:28:52
【问题描述】:

我在 Ionic 3 中创建新项目时遇到了糟糕的一天。我有以下版本:

  1. 离子 3.9.2
  2. npm 6.7.0
  3. 节点 v8.10.0

我使用的是 Ubuntu 18,每次我这样做:

sudo ionic start test blank

我收到这条消息:

        https://nodejs.org/download/release/v8.10.0/node-v8.10.0-headers.tar.gz
        gyp WARN install got an error, rolling back install
        gyp verb command remove [ '8.10.0' ]
        gyp verb remove using node-gyp dir: /home/abraham/.node-gyp
        gyp verb remove removing target version: 8.10.0
        gyp verb remove removing development files for version: 8.10.0
        gyp ERR! configure error 
        gyp ERR! stack Error: ENOENT: no such file or directory, open 
        '/home/abraham/='
        gyp ERR! stack     at Object.fs.openSync (fs.js:646:18)
        gyp ERR! stack     at Object.fs.readFileSync (fs.js:551:33)
        gyp ERR! stack     at readCAFile 
        (/home/abraham/Documentos/Ionic/IonicCurso/prueba/prueba/node_modules/node-gyp/lib/install.js:472:15)
        gyp ERR! stack     at download 
        (/home/abraham/Documentos/Ionic/IonicCurso/prueba/prueba/node_modules/node-gyp/lib/install.js:444:22)
        gyp ERR! stack     at 
        /home/abraham/Documentos/Ionic/IonicCurso/prueba/prueba/node_modules/node-gyp/lib/install.js:189:19
        gyp ERR! stack     at 
        /home/abraham/Documentos/Ionic/IonicCurso/prueba/prueba/node_modules/mkdirp/index.js:48:26
        gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:153:5)
        gyp ERR! System Linux 4.15.0-43-generic
        gyp ERR! command "/usr/bin/node" 
        "/home/abraham/Documentos/Ionic/IonicCurso/prueba/prueba/node_modules/node-gyp/bin/node-gyp.js" 
        "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" 
        "--libsass_ldflags=" "--libsass_library="
        gyp ERR! cwd 
        /home/abraham/Documentos/Ionic/IonicCurso/prueba/prueba/node_modules/node-sass
        gyp ERR! node -v v8.10.0
        gyp ERR! node-gyp -v v3.8.0
        gyp ERR! not ok 
        Build failed with error code: 1
        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":"x64"})

        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! node-sass@4.5.3 postinstall: `node scripts/build.js`
        npm ERR! Exit status 1
        npm ERR! 
        npm ERR! Failed at the node-sass@4.5.3 postinstall 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!     /home/abraham/.npm/_logs/2019-01-26T16_26_10_675Z-debug.log

我不知道是否需要重新安装 ionic,因为我已经尝试过:

npm rebuild node-sass

感谢您的帮助

【问题讨论】:

  • 可能与您正在使用的基础项目有关。这个命令是如何工作的? ionic start conference sidemenu ?
  • 我得到相同的结果 :c 与 sidemenu 选项 :c
  • npm 不需要 sudo,使用它被广泛认为是不好的做法。您可以通过搜索“不带 sudo 的 npm”来查找信息。除非这是我很难相信的最新 Ionic 特有的东西,否则您应该能够通过更改 npm 前缀来解决权限问题。请在此处查看我的答案以获得帮助:stackoverflow.com/a/54323596/1526037

标签: node.js ionic-framework npm ionic3


【解决方案1】:

有时您不想更改 npm 使用的默认目录(即 /usr)的所有权,因为这可能会导致一些问题,例如,如果您与其他用户共享系统。

相反,您可以将 npm 配置为完全使用不同的目录。在我们的例子中,这将是我们主文件夹中的一个隐藏目录。

为全局安装创建一个目录:

mkdir ~/.npm-global

配置 npm 以使用新的目录路径:

npm config set prefix '~/.npm-global'

打开或创建一个 ~/.profile 文件并添加以下行:

export PATH=~/.npm-global/bin:$PATH

回到命令行,更新你的系统变量:

source ~/.profile

【讨论】:

    猜你喜欢
    • 2021-02-18
    • 2020-10-23
    • 2020-02-12
    • 2019-03-08
    • 2018-09-07
    • 1970-01-01
    • 2019-04-14
    • 2021-01-18
    相关资源
    最近更新 更多