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

npm run build 构建报错 #4583

Closed
wsdqr001 opened this issue Jun 21, 2019 · 12 comments
Closed

npm run build 构建报错 #4583

wsdqr001 opened this issue Jun 21, 2019 · 12 comments

Comments

@wsdqr001
Copy link

wsdqr001 commented Jun 21, 2019

npm run build 时报错,node_modules下的多个包都有这个问题。怀疑是node_modules里,es6代码不能编译成es5代码导致。请问是需要手动配置webpack plugin来包含node_modules吗?错误信息如下:

/node_modules/consola/dist/consola.js:1
(function (exports, require, module, __filename, __dirname) { "use strict";function _interopDefault(u){return u&&"object"==typeof u&&"default"in u?u.default:u}var util=_interopDefault(require("util")),path=require("path"),fs=require("fs"),os=_interopDefault(require("os")),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(u,e){return u(e={exports:{}},e.exports),e.exports}function getCjsExportFromNamespace(u){return u&&u.default||u}var vendors=[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTI

SyntaxError: Unexpected token ...

at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Module._compile (/app/work/git/turnover/leo-web/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (module.js:580:10)
at Object.newLoader [as .js] (/app/work/git/turnover/leo-web/node_modules/pirates/lib/index.js:104:7)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ant-design-pro@2.3.1 build: umi build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ant-design-pro@2.3.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@wsdqr001
Copy link
Author

@sorrycc 麻烦大神帮忙看看,谢谢。我试了几个umi版本都不可以。

@guxiaobai
Copy link

upgrade v4

@chenshuai2144
Copy link
Collaborator

这个里面竟然有 fs,你导入了什么包?

@wsdqr001
Copy link
Author

这个里面竟然有 fs,你导入了什么包?

都是默认安装的,没有引入新的包。不只这个包会出现SyntaxError: Unexpected token ...错误,而且报错信息跟fs没关系呀。

@wsdqr001
Copy link
Author

upgrade v4

暂时还不想升级到V4,o(╥﹏╥)o

@afc163
Copy link
Member

afc163 commented Jun 24, 2019

sorrycc/blog#68

@chenshuai2144
Copy link
Collaborator

@wsdqr001 同一个问题的,你在浏览器里引入了 node 的包,所以就直接报错了

@wsdqr001
Copy link
Author

@wsdqr001 同一个问题的,你在浏览器里引入了 node 的包,所以就直接报错了
删掉node_modules,重新安装,发现了新的错误。崩溃,感觉是umi版本与dva版本问题?

ERROR Failed to compile with 1 errors 14:40:18

This dependency was not found:

  • @tmp/history in ./src/pages/.umi-production/dva.js

To install it, you can run: npm install --save @tmp/history
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ant-design-pro@2.3.1 build: umi build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ant-design-pro@2.3.1 build 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:

@chenshuai2144
Copy link
Collaborator

这个是 umi 的问题。你升级所有的依赖到最新就可以了,看一下你的项目里是不是用 *.lock 文件

@wsdqr001
Copy link
Author

这个是 umi 的问题。你升级所有的依赖到最新就可以了,看一下你的项目里是不是用 *.lock 文件

升级最新umi解决了这个问题,谢谢啦。

@wsdqr001
Copy link
Author

sorrycc/blog#68
@chenshuai2144 @afc163
新增了.webpackrc.js,内容如下:
export default {
es5ImcompatibleVersions: true,
extraBabelIncludes: ['node_modules/update-notifier', 'node_modules/consola'],
};

npm run build的时候还是报错了,报错信息如下:

/app/work/git/turnover/virgo-web/node_modules/update-notifier/index.js:132
...options
^^^

SyntaxError: Unexpected token ...
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/app/work/git/turnover/virgo-web/node_modules/umi/lib/cli.js:27:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Virgo@2.3.1 build: umi build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Virgo@2.3.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@wsdqr001
Copy link
Author

node升级到V10解决问题,closed

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

4 participants