问答详情
源自:4-2 创建添加音乐窗口

fs.existsSync is not a function

Uncaught TypeError: fs.existsSync is not a function

    at getElectronPath (webpack-internal:///./node_modules/electron/index.js:7)


提问者:枫枫枫枫枫枫 2020-09-27 13:08

个回答

  • 慕虎557368
    2021-02-21 22:52:22

    1. 请确定你正确导入了fs:const fs = require("fs")

    2. 如果导入了,command+单击,看源码的实现


    我这里测试是正常的

    代码

    ```

    const appDataPath = app.getPath("userData")

    const exist = fs.existsSync(appDataPath)

    console.log("----------")

    console.log(exist)

    ```

    输出

    ```

    [nodemon] starting `electron .`

    ----------

    true

    ```