npm run build 运行报错处理

最近电脑重装系统后运行 npm run dev 正常运行,npm run build 打包文件,提示如下错误:

Administrator@WIN-9PL8VSAPS0 MINGW64 /h/project_latest

$ npm run build

> demo@ build H:\project_package_version_latest

> cross-env NODE_ENV=production webpack --progress --hide-modules

'webpack' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒

▒▒▒▒▒▒▒▒▒ļ▒▒▒

npm ERR! Windows_NT 6.1.7601

npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\      node_modules\\npm\\bin\\npm-cli.js" "run" "build"

npm ERR! node v6.9.4

npm ERR! npm  v3.10.10

npm ERR! code ELIFECYCLE

npm ERR! demo@ build: `cross-env NODE_ENV=production webpack --progress --hide-m      odules`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the demo@ build script 'cross-env NODE_ENV=production webpack      --progress --hide-modules'.

npm ERR! Make sure you have the latest version of node.js and npm installed.

npm ERR! If you do, this is most likely a problem with the demo package,

npm ERR! not with npm itself.

npm ERR! Tell the author that this fails on your system:

npm ERR!    cross-env NODE_ENV=production webpack --progress --hide-modules

npm ERR! You can get information on how to open an issue for this project with:

npm ERR!    npm bugs demo

npm ERR! Or if that isn't available, you can get their info via:

npm ERR!    npm owner ls demo

npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

npm ERR!    H:\project_package_version_latest\npm-debug.log

家里的电脑上可以正常运行,考虑是缺少了什么文件,但不知道是哪个文件,网上搜索相关问题,最后看到一个 

'NODE_ENV' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒▒▒▒▒▒▒▒▒▒ļ▒▒▒ 

报错,于是回头看我那个

 'webpack' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒▒▒▒▒▒▒▒▒▒ļ▒▒▒

之前一直没注意到这个,这就是缺少的文件,原来我在项目本地安装了webpack,重装系统后未全局安装。

先全局安装webpack,

$ npm install webpack -g

C:\Users\Administrator\AppData\Roaming\npm\webpack -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js

C:\Users\Administrator\AppData\Roaming\npm

`-- webpack@1.14.0

+-- acorn@3.3.0

+-- async@1.5.2

+-- clone@1.0.2

+-- enhanced-resolve@0.9.1

| +-- graceful-fs@4.1.11

| `-- memory-fs@0.2.0

+-- interpret@0.6.6

+-- loader-utils@0.2.16

| +-- big.js@3.1.3

| +-- emojis-list@2.1.0

| +-- json5@0.5.1

| `-- object-assign@4.1.1

+-- memory-fs@0.3.0

| +-- errno@0.1.4

| | `-- prr@0.0.0

| `-- readable-stream@2.2.2

|  +-- buffer-shims@1.0.0

|  +-- core-util-is@1.0.2

|  +-- inherits@2.0.3

|  +-- isarray@1.0.0

|  +-- process-nextick-args@1.0.7

|  `-- util-deprecate@1.0.2

+-- mkdirp@0.5.1

| `-- minimist@0.0.8

+-- node-libs-browser@0.7.0

| +-- assert@1.4.1

| +-- browserify-zlib@0.1.4

| | `-- pako@0.2.9

| +-- buffer@4.9.1

| | +-- base64-js@1.2.0

| | `-- ieee754@1.1.8

| +-- console-browserify@1.1.0

| | `-- date-now@0.1.4

| +-- constants-browserify@1.0.0

| +-- crypto-browserify@3.3.0

| | +-- browserify-aes@0.4.0

| | +-- pbkdf2-compat@2.0.1

| | +-- ripemd160@0.2.0

| | `-- sha.js@2.2.6

| +-- domain-browser@1.1.7

| +-- events@1.1.1

| +-- https-browserify@0.0.1

| +-- os-browserify@0.2.1

| +-- path-browserify@0.0.0

| +-- process@0.11.9

| +-- punycode@1.4.1

| +-- querystring-es3@0.2.1

| +-- stream-browserify@2.0.1

| +-- stream-http@2.6.3

| | +-- builtin-status-codes@3.0.0

| | +-- to-arraybuffer@1.0.1

| | `-- xtend@4.0.1

| +-- string_decoder@0.10.31

| +-- timers-browserify@2.0.2

| | `-- setimmediate@1.0.5

| +-- tty-browserify@0.0.0

| +-- url@0.11.0

| | +-- punycode@1.3.2

| | `-- querystring@0.2.0

| +-- util@0.10.3

| | `-- inherits@2.0.1

| `-- vm-browserify@0.0.4

|  `-- indexof@0.0.1

+-- optimist@0.6.1

| `-- wordwrap@0.0.3

+-- supports-color@3.2.3

| `-- has-flag@1.0.0

+-- tapable@0.1.10

+-- uglify-js@2.7.5

| +-- async@0.2.10

| +-- source-map@0.5.6

| +-- uglify-to-browserify@1.0.2

| `-- yargs@3.10.0

|  +-- camelcase@1.2.1

|  +-- cliui@2.1.0

|  | +-- center-align@0.1.3

|  | | +-- align-text@0.1.4

|  | | | +-- longest@1.0.1

|  | | | `-- repeat-string@1.6.1

|  | | `-- lazy-cache@1.0.4

|  | +-- right-align@0.1.3

|  | `-- wordwrap@0.0.2

|  +-- decamelize@1.2.0

|  `-- window-size@0.1.0

+-- watchpack@0.2.9

| +-- async@0.9.2

| `-- chokidar@1.6.1

|  +-- anymatch@1.3.0

|  | +-- arrify@1.0.1

|  | `-- micromatch@2.3.11

|  |  +-- arr-diff@2.0.0

|  |  | `-- arr-flatten@1.0.1

|  |  +-- array-unique@0.2.1

|  |  +-- braces@1.8.5

|  |  | +-- expand-range@1.8.2

|  |  | | `-- fill-range@2.2.3

|  |  | |  +-- is-number@2.1.0

|  |  | |  +-- isobject@2.1.0

|  |  | |  `-- randomatic@1.1.6

|  |  | +-- preserve@0.2.0

|  |  | `-- repeat-element@1.1.2

|  |  +-- expand-brackets@0.1.5

|  |  | `-- is-posix-bracket@0.1.1

|  |  +-- extglob@0.3.2

|  |  +-- filename-regex@2.0.0

|  |  +-- kind-of@3.1.0

|  |  | `-- is-buffer@1.1.4

|  |  +-- normalize-path@2.0.1

|  |  +-- object.omit@2.0.1

|  |  | +-- for-own@0.1.4

|  |  | | `-- for-in@0.1.6

|  |  | `-- is-extendable@0.1.1

|  |  +-- parse-glob@3.0.4

|  |  | +-- glob-base@0.3.0

|  |  | `-- is-dotfile@1.0.2

|  |  `-- regex-cache@0.4.3

|  |    +-- is-equal-shallow@0.1.3

|  |    `-- is-primitive@2.0.0

|  +-- async-each@1.0.1

|  +-- glob-parent@2.0.0

|  +-- is-binary-path@1.0.1

|  | `-- binary-extensions@1.8.0

|  +-- is-glob@2.0.1

|  | `-- is-extglob@1.0.0

|  +-- path-is-absolute@1.0.1

|  `-- readdirp@2.1.0

|    +-- minimatch@3.0.3

|    | `-- brace-expansion@1.1.6

|    |  +-- balanced-match@0.4.2

|    |  `-- concat-map@0.0.1

|    `-- set-immediate-shim@1.0.1

`-- webpack-core@0.6.9

+-- source-list-map@0.1.8

`-- source-map@0.4.4

`-- amdefine@1.0.1

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\webpack\node_modules\chokidar\node_modules\fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

webpack安装成功,开始打包 npm run build

$ npm run build

> demo@ build H:\project_package_version_latest

> cross-env NODE_ENV=production 35% building modules 212/227 modules 15 active ...on_latest\src\assets\page-content.css

正在打包……

$ npm run build

Hash: b4ec0192fe9ac74b479e                      Version: webpack 2.1.0-beta.10                                                  Time: 61343ms

打包成功。

网上看到一些类似的问题,基本都是

'webpack' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒▒▒▒▒▒▒▒▒▒ļ▒▒▒

提示信息所指向的问题。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容