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

An Webpack Error #4

Closed
VGdaocao opened this issue Nov 14, 2016 · 7 comments
Closed

An Webpack Error #4

VGdaocao opened this issue Nov 14, 2016 · 7 comments

Comments

@VGdaocao
Copy link

你好,我是您的读者,在运行第四章源码 报以下错:

ERROR in Cannot find module 'escope'
 @ multi app

ERROR in Path must be a string. Received undefined

命令执行顺序:

npm i 
npm run build
npm run dev  //(改成了127.0.0.1)

未找到原因,能否帮忙解答下~

@vikingmute
Copy link
Owner

@VGdaocao 你好
看起来像是 npm 安装的时候的出现问题,少安装了一些模块,这种情况经常出现,你可以尝试重新安装
rm -rf node_modules
npm install
如果能提供node & npm 版本,并且有完整的错误截图,会更加容易定位错误,谢谢。

而且:
运行 npm run dev 之前是不需要 npm run build 的,这是两个不同目的的命令。

@vince-fly
Copy link

ERROR in ./app/components/List.jsx

/Users/xxx/web/webpack-react-codes/chapter5/part1/app/components/List.jsx
8:36 error Unexpected block statement surrounding arrow body arrow-body-style

✖ 1 problem (1 error, 0 warnings)

我也碰到同样的,问题,求解~
其中第四章里也有类似的错误
mac osx 10.12.1
node 6.9.1
npm 3.10.8

@michealcat
Copy link

我也遇到了同样的问题,但是我排查了很多地方,花费很多时间才找到是那个地方报的错:
1.我是完全按照作者书中一步步做的,并没有错误。
2.是HtmlwebpackPlugin这个插件报的错,如果去掉就不会出错,求报错原因及到底应该怎么配置。

@nighca
Copy link
Collaborator

nighca commented Nov 21, 2016

@VGdaocao @vince-fly @michealcat 感谢反馈,经排查,问题

ERROR in Path must be a string. Received undefined

是 Node.js 6.x 的向前不兼容改动导致的(本书写作时使用 Node.js 版本 5.0.0),新版本的 html-webpack-plugin 修复了 6.x 下的这个问题。

所以使用 Node.js 6.x 的同学,可以升级 html-webpack-plugin(更新本代码库后重新 npm i 安装依赖即可),即可解决问题。

@vikingmute
Copy link
Owner

@vince-fly @VGdaocao @michealcat 已经修复 请再试试看

@nighca
Copy link
Collaborator

nighca commented Nov 21, 2016

@vince-fly

ERROR in ./app/components/List.jsx

/Users/xxx/web/webpack-react-codes/chapter5/part1/app/components/List.jsx
8:36 error Unexpected block statement surrounding arrow body arrow-body-style

✖ 1 problem (1 error, 0 warnings)

这个问题是 eslint 的代码规范检查报的错,要求能够用简单形式的箭头函数(() => () 而不是 () => { return () })就尽可能用简单形式,应该是这条规则的小版本发布的改动导致的,我们修复了下这个问题,更新下代码库即可。

最后,感谢各位反馈,我们添加npm-shrinkwrap.json 来对依赖库的版本进行更精确的控制,避免以后再出现这种依赖包的小版本升级导致的新问题。

@vince-fly
Copy link

赞!!! @nighca @michealcat

@nighca nighca closed this as completed Nov 23, 2016
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

No branches or pull requests

5 participants