0

我这里很绿。我以前在这个(macosx)上运行过 gatsby。它已停止工作 - 可能是由于某处的安装或环境变量?

首先注意到模块构建失败:错误:找不到相对于目录“/Users/3Legs”的预设“流”

然后在安装 babel 预设后:

npm install --global --save-dev babel-preset-flow

我收到上述消息:

gatsby develop

...找不到模块“gatsby/dist/commands/develop”

下面是完整的跟踪 + babelrc

Michaels-MacBook-Air:mggatsby 3Legs$

gatsby new test

-bash: /usr/local/bin/gatsby: 没有这样的文件或目录 Michaels-MacBook-Air:mggatsby 3Legs$

npm install --global gatsby-cli

WARN registry Unexpected warning for registry.npmjs.org: Miscellaneous Warning EINTEGRITY: sha1-xRn2KfhrOlvtuliojTETCe7Al/k= integrity checksum failed when using sha1: wanted sha1-xRn2KfhrOlvtuliojTETCe7Al/k= but got sha512-vE2hT1D0HLZCLLclfBSfkfTTedhVj0fubHpJBHKwwUWX0nSbhPAfk+SG9rTX95BYNmau8rGFfCeaT6T5OW1C2A==. (455516 bytes)
WARN registry Using stale package data from registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha1-buxr+wdCHiFIx1xrunJCH4UwqCY= integrity checksum failed when using sha1: wanted sha1-buxr+wdCHiFIx1xrunJCH4UwqCY= but got sha512-+ktMAh1Jwas+TnGodfCfjUbJKoANqPaJFN0z0iqh41eqD8dvguNzcitVSBSVK1pidz0AqGbLKcoVuVLRVZ/aVg==. (42903 bytes)
WARN registry Using stale package data from registry.npmjs.org/ due to a request error during revalidation.
/usr/local/bin/gatsby -> /usr/local/lib/node_modules/gatsby-cli/lib/index.js
+ gatsby-cli@1.1.1
added 153 packages, removed 5 packages and updated 1 package in 10.573s
Michaels-MacBook-Air:mggatsby 3Legs$ 
    gatsby new test
info Creating new site from git: git://github.com/gatsbyjs/gatsby-starter-default.git
Cloning into 'test'...
remote: Counting objects: 566, done.
remote: Total 566 (delta 0), reused 0 (delta 0), pack-reused 566
Receiving objects: 100% (566/566), 358.35 KiB | 187.00 KiB/s, done.
Resolving deltas: 100% (316/316), done.
success Created starter directory layout
info Installing packages...
yarn install v0.27.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "eslint-config-fbjs@1.1.1" has unmet peer dependency "babel-eslint@^6.1.2".
warning "eslint-config-fbjs@1.1.1" has unmet peer dependency "eslint@^3.0.0".
warning "eslint-config-fbjs@1.1.1" has unmet peer dependency "eslint-plugin-babel@^3.3.0".
warning "eslint-config-fbjs@1.1.1" has unmet peer dependency "eslint-plugin-flowtype@^2.15.0".
warning "eslint-config-fbjs@1.1.1" has unmet peer dependency "eslint-plugin-react@^5.2.2".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 47.94s.
Michaels-MacBook-Air:mggatsby 3Legs$ 
    cd test
Michaels-MacBook-Air:test 3Legs$ 
    gatsby develop
success delete html files from previous builds — 0.010 s
success open and validate gatsby-config.js — 0.006 s
success copy gatsby files — 0.028 s
success source and transform nodes — 0.045 s
success building schema — 0.134 s
success createLayouts — 0.039 s
success createPages — 0.016 s
success createPagesStatefully — 0.016 s
success extract queries from components — 0.118 s
success run graphql queries — 0.030 s
success write out page data — 0.006 s
success update schema — 0.094 s

info bootstrap finished - 3.856 s

error There was an error compiling the html.js component for the development server.

See our docs page on debugging HTML builds for help ...

错误:模块构建失败:错误:找不到相对于目录“/Users/3Legs”的预设“流”

Michaels-MacBook-Air:test 3Legs$ 
    npm install --save-dev babel-preset-flow 
    npm WARN gentlyRm not removing /Users/3Legs/react/mggatsby/test/node_modules/.bin/gatsby as it wasn't installed by /Users/3Legs/react/mggatsby/test/node_modules/gatsby
    npm WARN gentlyRm not removing /Users/3Legs/react/mggatsby/test/node_modules/.bin/semver as it wasn't installed by /Users/3Legs/react/mggatsby/test/node_modules/semver
    npm WARN gentlyRm not removing /Users/3Legs/react/mggatsby/test/node_modules/jspm-registry/node_modules/.bin/semver as it wasn't installed by /Users/3Legs/react/mggatsby/test/node_modules/jspm-registry/node_modules/semver
    npm WARN gentlyRm not removing /Users/3Legs/react/mggatsby/test/node_modules/.bin/browserslist as it wasn't installed by /Users/3Legs/react/mggatsby/test/node_modules/browserslist
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN gatsby-starter-default@1.0.0 No repository field.


+ babel-preset-flow@6.23.0
removed 1375 packages and updated 6 packages in 17.729s
Michaels-MacBook-Air:test 3Legs$ 
    gatsby develop
/usr/local/bin/gatsby develop

Options:
  -h, --help     Show help                                                   [boolean]
  -H, --host     Set host. Defaults to localhost                              [string]
  -p, --port     Set port. Defaults to 8000                 [string] [default: "8000"]
  -o, --open     Open the site in your browser for you.                      [boolean]
  -v, --version  Show version number                                         [boolean]

error There was a problem loading the local develop command. Gatsby may not be installed.

错误:找不到模块“gatsby/dist/commands/develop”

  - index.js:17 resolveFileName
    [lib]/[gatsby-cli]/[resolve-from]/index.js:17:39

  - index.js:31 resolveFrom
    [lib]/[gatsby-cli]/[resolve-from]/index.js:31:9

  - index.js:34 module.exports
    [lib]/[gatsby-cli]/[resolve-from]/index.js:34:41

  - index.js:4 module.exports.moduleId
    [lib]/[gatsby-cli]/[resolve-cwd]/index.js:4:30

  - create-cli.js:35 resolveLocalCommand
    [lib]/[gatsby-cli]/lib/create-cli.js:35:22

  - create-cli.js:66 Object.handler
    [lib]/[gatsby-cli]/lib/create-cli.js:66:7

  - command.js:233 Object.self.runCommand
    [lib]/[gatsby-cli]/[yargs]/lib/command.js:233:22

  - yargs.js:990 Object.Yargs.self._parseArgs
    [lib]/[gatsby-cli]/[yargs]/yargs.js:990:30

  - yargs.js:532 Object.Yargs.self.parse
    [lib]/[gatsby-cli]/[yargs]/yargs.js:532:23

  - create-cli.js:163 module.exports
    [lib]/[gatsby-cli]/lib/create-cli.js:163:154

  - index.js:122 Object.<anonymous>
    [lib]/[gatsby-cli]/lib/index.js:122:1

Michaels-MacBook-Air:~ 3Legs$ 
    cat .babelrc 
{
  "presets": ["flow"]
}
4

1 回答 1

1

NPM 似乎正在删除模块,因为没有 package-lock.json。不确定这是否是新行为,但在过去的几天里已经影响了很多人。

您需要做的就是删除 node_modules 和那里的任何锁定文件并运行npm install.

于 2017-08-26T21:46:14.463 回答