重新安装gatsby失败,找不到模块“检测端口”

时间:2020-05-21 23:57:35

标签: npm gatsby nvm

所以我要做的就是安装gatsby(第一次在我的系统上)。

我的操作系统是:macOS 10.13.6

我的第一步是确保节点/ npm的版本正确:

nvm install 10
npm -v
 6.14.4
node -v
 v10.20.1

然后我只是尝试安装gatsby cli:

npm install -g gatsby-cli
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/Users/me/.nvm/versions/node/v10.20.1/bin/gatsby -> /Users/me/.nvm/versions/node/v10.20.1/lib/node_modules/gatsby-cli/lib/index.js

> core-js@2.6.11 postinstall /Users/me/.nvm/versions/node/v10.20.1/lib/node_modules/gatsby-cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> gatsby-telemetry@1.3.8 postinstall /Users/me/.nvm/versions/node/v10.20.1/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node src/postinstall.js || true


> gatsby-cli@2.12.31 postinstall /Users/me/.nvm/versions/node/v10.20.1/lib/node_modules/gatsby-cli
> node scripts/postinstall.js

npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

+ gatsby-cli@2.12.31
added 670 packages from 470 contributors in 26.613s

好像完成了吗?最后,我尝试运行一些东西:

gatsby --help

/Users/me/.nvm/versions/node/v10.20.1/lib/node_modules/gatsby-cli/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

Error: Cannot find module 'detect-port'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/me/.nvm/versions/node/v10.20.1/lib/node_modules/gatsby-cli/lib/recipes.js:18:42)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

我的设置可能有问题吗?谢谢。

1 个答案:

答案 0 :(得分:1)

以下是当前gitub问题的链接:https://github.com/gatsbyjs/gatsby/issues/24325

安装纱线并运行yarn buildyarn develop是目前的解决方法。