简体   繁体   English

NodeJS/nextJS 应用程序未在 windows 机器上运行

[英]NodeJS/nextJS app is not running on windows machine

I'm developing a nextJS app on a macOS machine.我正在 macOS 机器上开发 nextJS 应用程序。 After running npm install , I moved all the files to a windows (10) machine, which has no internet connection.运行npm install后,我将所有文件移动到没有互联网连接的 windows (10) 机器上。 Running npm run dev is surprisingly not working.运行npm run dev令人惊讶地不起作用。 I do get an error which can be losley translated to the command "next" is written wrongly or cannot be found .我确实收到一个错误,可以将其翻译为the command "next" is written wrongly or cannot be found

I do not see, what is wrong with my nextJS app - which is just the official example app, so it should work (and it is working on my macOS machine).我看不出,我的 nextJS 应用程序有什么问题 - 这只是官方示例应用程序,所以它应该可以工作(并且它正在我的 macOS 机器上工作)。

Is there any configuration missing on the windows machine? windows机器上是否缺少配置? Running node -v and npm -v are returning the latest version.运行node -vnpm -v正在返回最新版本。

output output

C:\Users\User\nextjs-blog>npm run dev

> learn-starter@0.1.0 dev C:\Users\User\nextjs-blog
> next dev

Der Befehl "next" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! learn-starter@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the learn-starter@0.1.0 dev 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!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-07-02T07_18_21_223Z-debug.log

log日志

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v12.18.1
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle learn-starter@0.1.0~predev: learn-starter@0.1.0
6 info lifecycle learn-starter@0.1.0~dev: learn-starter@0.1.0
7 verbose lifecycle learn-starter@0.1.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle learn-starter@0.1.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\User\nextjs-blog\node_modules\.bin;C:\Users\User\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Users\User\AppData\Local\Microsoft\WindowsApps;;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin
9 verbose lifecycle learn-starter@0.1.0~dev: CWD: C:\Users\User\nextjs-blog
10 silly lifecycle learn-starter@0.1.0~dev: Args: [ '/d /s /c', 'next dev' ]
11 silly lifecycle learn-starter@0.1.0~dev: Returned: code: 1  signal: null
12 info lifecycle learn-starter@0.1.0~dev: Failed to exec dev script
13 verbose stack Error: learn-starter@0.1.0 dev: `next dev`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid learn-starter@0.1.0
15 verbose cwd C:\Users\User\nextjs-blog
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v12.18.1
19 verbose npm  v6.14.5
20 error code ELIFECYCLE
21 error errno 1
22 error learn-starter@0.1.0 dev: `next dev`
22 error Exit status 1
23 error Failed at the learn-starter@0.1.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I deployed node.js app on CentOS with no internet connection.我在没有互联网连接的情况下在 CentOS 上部署了 node.js 应用程序。

Develop on Mac and yarn install, I moved all Files, but get errors on CentOS.在 Mac 上开发并安装 yarn,我移动了所有文件,但在 CentOS 上出现错误。

I finish that project with npm install with CentOS in virtual machine.我使用 npm 在虚拟机中安装 CentOS 来完成该项目。

=== ===

Here is not any miracles, and can not be option like npm install --linux-but-i-am-on-windows.这里没有任何奇迹,也不能像 npm install --linux-but-i-am-on-windows 这样的选项。 You just need linux machine with interned to build your product on it (say perform npm install), and then copy project to the prod server.您只需要带实习生的 linux 机器在其上构建您的产品(比如执行 npm 安装),然后将项目复制到产品服务器。 Jenkins or Bamboo could help Jenkins 或 Bamboo 可以提供帮助

Is there a difference between npm install on windows & linux npm 安装在 windows 和 linux 上是否有区别

I have so many time this issue with reactjs or nextjs我有很多次与 reactjs 或 nextjs 相关的问题

I first do :我首先做

STEP 1: clear the cache npm cache clean --force STEP 1: 清除缓存npm cache clean --force

STEP 2: delete node-modules and package-lock-json第 2 步:删除node-modulespackage-lock-json

rm -rf node-modules package-lock-json or remove them manuelly rm -rf node-modules package-lock-json或手动删除它们

STEP 3: install 'npm'第 3 步:安装“npm”

npm install

And then npm start然后npm start

If that FAIL : you can debug on VSCode如果失败:您可以在 VSCode 上进行调试

On the package.json' file click on Debug` buttonpackage.json' file click on Debug` 按钮

Chose the right select and the debug's extension will run and debug.选择正确的 select 并且调试的扩展将运行和调试。

At the end npm start or 'npm run dev`最后npm start或“npm run dev”

reactjs next.js VSC reactjs next.js VSC

You can get it to work if you run如果你运行,你可以让它工作

npm install --force npm 安装 --force

that gets the app to show when I ran it on localhost:3000当我在 localhost:3000 上运行它时,它会显示应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM