更新:经过测试,这似乎扩展到了node_modules / .bin中的任何软件包。本地bin出现在npm错误日志中,但似乎找不到或执行任何本地安装的软件包。将类似./node_modules/.bin或$(npm bin)的内容添加到PATH确实可以,但这似乎不需要解决。
我尝试按照next.js的非常基本的设置进行操作,但是不成功。我很想在全球范围内安装下一个,但是基于我在他们的Github上看到的问题,这不是必须的。我环顾了Google和SO,但找不到任何帮助我的东西。
我一直执行setup的第一步,一直运行npm run dev
。该命令失败,提示sh: next: command not found
这是npm错误的日志。在我看来,该项目的node_modules / .bin的路径位于npm run所查找的路径中。我查看了该文件夹,接下来是该文件夹。真的不确定我应该从那里去哪里。
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/Users/myusername/.npm-packages/bin/npm',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm@6.5.0
3 info using node@v8.9.4
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle project@1.0.0~predev: project@1.0.0
6 info lifecycle project@1.0.0~dev: project@1.0.0
7 verbose lifecycle project@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle project@1.0.0~dev: PATH: /Users/myusername/.npm-packages/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/myusername/path/to/project/node_modules/.bin:/Users/myusername/.npm-packages/bin:/usr/local/bin:/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
9 verbose lifecycle project@1.0.0~dev: CWD: /Users/myusername/path/to/project
10 silly lifecycle project@1.0.0~dev: Args: [ '-c', 'next' ]
11 info lifecycle project@1.0.0~dev: Failed to exec dev script
12 verbose stack Error: project@1.0.0 dev: `next`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/Users/myusername/.npm-packages/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at emitTwo (events.js:126:13)
12 verbose stack at ChildProcess.emit (events.js:214:7)
12 verbose stack at maybeClose (internal/child_process.js:925:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
13 verbose pkgid project@1.0.0
14 verbose cwd /Users/myusername/path/to/project
15 verbose Darwin 18.2.0
16 verbose argv "/usr/local/bin/node" "/Users/myusername/.npm-packages/bin/npm" "run" "dev"
17 verbose node v8.9.4
18 verbose npm v6.5.0
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error project@1.0.0 dev: `next`
23 error spawn ENOENT
24 error Failed at the project@1.0.0 dev script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]