Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot covert undefined or null to object when run npm run dev for backend #92

Closed
lineezhang opened this issue Oct 17, 2019 · 9 comments · Fixed by #93
Closed

Cannot covert undefined or null to object when run npm run dev for backend #92

lineezhang opened this issue Oct 17, 2019 · 9 comments · Fixed by #93

Comments

@lineezhang
Copy link

如下图所示

image

@initial-desire
Copy link

initial-desire commented Oct 17, 2019

当时也遇到这个问题,在作者的帮助下解决了。
成功启动的步骤如下:

git clone https://github.com/ly525/luban-h5.git
cd luban-h5/back-end/h5-api/
yarn
npm run dev

  1. 先把node_modules 删除,重新下载
  2. yarn的仓库最好换成淘宝的,不然下载下来的 node_modules 模块可能有问题
# 改成 taobao 的源:
yarn config set registry https://registry.npm.taobao.org

我的版本信息:

node -v: v10.16.3
npm -v:6.9.0
yarn -v:1.19.1

@lineezhang
Copy link
Author

还有新的问题

image
出现这个错误,但是不影响使用,只是点击编辑按钮,一进来,谷歌console就抛出这个异常

@ly525
Copy link
Owner

ly525 commented Oct 17, 2019

@lineezhang

  1. 我猜测你应该使用的是 npm install 的方式来安装依赖的,
  2. 请注意:文档中提及的是使用 yarn 来安装依赖。
  3. 因为这个项目是通过yarn 来管理版本依赖的,特别是项目中包含了 yarn.lock 文件来保证所有机器上安装的依赖的版本都是一致的。
  4. 主要原因是因为通过 npm 安装的 strapi-hook-ejs 会升级到最新版,它与 strapi@3.0.0-beta.13 会有一些不兼容的情况
  5. 这个是我的锅,我看了下,是我在 package.json 中的 strapi-hook-ejs 的版本号前面添加了 ^ 符号,导致npm install 的时候,strapi-hook-ejs 升级了,我稍微晚点去更新下代码和文档

非常感谢你的反馈,👍,下次提问之前可以提供更多的信息会更有助与我们排查问题,感谢!

@initial-desire 非常感谢小伙伴的回答

@ly525
Copy link
Owner

ly525 commented Oct 17, 2019

没有收到反馈,暂时关闭

@yoolsylva
Copy link

yoolsylva commented Oct 18, 2019

Hi, thank you for great work!
But i got the same issue here
Screen Shot 2019-10-18 at 11 14 19 AM

MacOS mojave
node -v: v10.16.2 (and v12.2.0 still error)
npm -v:6.11.3
yarn -v:1.19.1

@ly525 ly525 changed the title 后端h5-api项目起步不了,报错 Cannot covert undefined or null to object when run npm run dev for backend Oct 18, 2019
@ly525
Copy link
Owner

ly525 commented Oct 18, 2019

@yoolsylva

  1. I guess you may use the npm install to install the dependencies
  2. note: the document mentions that you should use yarn to install the dependencies.
  3. In this project, we use yarn.lock to get consistent installs across machines.
  4. Of course, the main reason is that strapi-hook-ejs installed through NPM will be upgraded to the latest version, which will have some incompatibilities with strapi@3.0.0-beta. 13
  5. it's my fault because I add the ^ before the version number of strapi-hook-ejs in package.json, I will update the docs and the package.json later

So, you can

git clone https://github.com/ly525/luban-h5.git
cd luban-h5/back-end/h5-api/
yarn
npm run dev

It should be working properly.

@yoolsylva
Copy link

yoolsylva commented Oct 18, 2019

@ly525
Thank you, it worked! For any one get the same issue:
I run npm install first, and for some reason, yarn.lock changed. So after that, although i deleted node_module folder, and run again cmd:
yarn
npm run dev
but issue still happened.
I realize yarn.lock changed and after revert yarn.lock -> delete node_module -> install package again, it worked!

@shanetianxia
Copy link

image
image
image
构建完成之后,后端的h5-api/public里面会多一个文件夹 engine-assets,已经生成,但是还是无法预览

@ly525
Copy link
Owner

ly525 commented Nov 21, 2019

image
image
image
构建完成之后,后端的h5-api/public里面会多一个文件夹 engine-assets,已经生成,但是还是无法预览

好的,收到。我周末看下。暂时先试用预览模式来看预览效果吧,预览弹框和预览模式用的同样的代码。ps:建议单独开一个issue吧,要不可能会打扰到其他人😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants