Angular-cli: really strange error - TypeError: Data must be a string or a buffer

Created on 14 Feb 2017  路  14Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Mac OSX (macOS 10.12.3 (16D32)

Versions.

cli-version: 1.0.0-beta.31
node-version: v6.9.5
angular version: 4.0.0-beta.7

After upgrading to cli-version 1.0.0-beta.31 (from 1.0.0-beta.30) I have the following error on building

** NG Live Development Server is running on http://localhost:4200. **
 86% hashingcrypto.js:74
  this._handle.update(data, encoding);
               ^

TypeError: Data must be a string or a buffer
    at TypeError (native)
    at Hash.update (crypto.js:74:16)
    at HarmonyExportImportedSpecifierDependency.updateHash (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js:144:8)
    at /Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/DependenciesBlock.js:33:5
    at Array.forEach (native)
    at NormalModule.DependenciesBlock.updateHash (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/DependenciesBlock.js:32:20)
    at NormalModule.Module.updateHash (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Module.js:162:41)
    at NormalModule.updateHash (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/NormalModule.js:327:30)
    at modules.forEach.m (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Chunk.js:253:31)
    at Array.forEach (native)
    at Chunk.updateHash (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Chunk.js:253:16)
    at Compilation.createHash (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Compilation.js:1121:10)
    at sealPart2 (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Compilation.js:605:9)
    at next (/Users/martin/_dev/angularx/cli-test2/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.<anonymous> (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/ProgressPlugin.js:110:5)
    at next (/Users/martin/_dev/angularx/cli-test2/node_modules/tapable/lib/Tapable.js:140:14)
    at ExtractTextPlugin.<anonymous> (/Users/martin/_dev/angularx/cli-test2/node_modules/extract-text-webpack-plugin/index.js:305:5)
    at /Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:356:16
    at iteratorCallback (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:936:13)
    at /Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:840:16
    at /Users/martin/_dev/angularx/cli-test2/node_modules/extract-text-webpack-plugin/index.js:289:6
    at /Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:356:16
    at iteratorCallback (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:936:13)
    at /Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:840:16
    at /Users/martin/_dev/angularx/cli-test2/node_modules/extract-text-webpack-plugin/index.js:286:13
    at /Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:941:9)
    at eachOf (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:991:5)
    at Object.eachLimit (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:3089:3)
    at /Users/martin/_dev/angularx/cli-test2/node_modules/extract-text-webpack-plugin/index.js:260:11
    at /Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:941:9)
    at eachOf (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:991:5)
    at Object.eachLimit (/Users/martin/_dev/angularx/cli-test2/node_modules/async/dist/async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (/Users/martin/_dev/angularx/cli-test2/node_modules/extract-text-webpack-plugin/index.js:257:10)
    at Compilation.applyPluginsAsyncSeries (/Users/martin/_dev/angularx/cli-test2/node_modules/tapable/lib/Tapable.js:142:13)
    at Compilation.seal (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Compilation.js:570:8)
    at /Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Compiler.js:474:16
    at /Users/martin/_dev/angularx/cli-test2/node_modules/tapable/lib/Tapable.js:225:11
    at _addModuleChain (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Compilation.js:472:11)
    at processModuleDependencies.err (/Users/martin/_dev/angularx/cli-test2/node_modules/webpack/lib/Compilation.js:443:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I am not really sure if the cause of the error is the upgrade

Can anybody of you give me a hint what's wrong...

Most helpful comment

Had the same problem. I deleted a component which was referenced in an index.ts file using export * from './xxx.component';

After removing that reference from index.ts the error was gone.

All 14 comments

Had the same problem. I deleted a component which was referenced in an index.ts file using export * from './xxx.component';

After removing that reference from index.ts the error was gone.

@ciesielskico My problem is really strange - I created a new cli application (1.0.0-beta.31, ng4) and ported my existing application step by step (to hit what the problem is).
But in the end I could not found the problem, BUT I had an application which works.

As soon as I clone this working application (and install all dependencies via npm) the error is present again...

This is so frustrating...

Hi @maku,
I also tried re-creating your issue.
I've noticed that if the typescript version is lower than 2.1.6 the build throws errors.
Could that be the issue?

goodnessSquad

Finally I got the reason of the error. I use a library in my client project which is also under development. So I "link" it via "npm link ...".
After removing node_modules the link information is not present anymore.

The result is this very, very indifferent message.
After linking it again everything is okay....
I cannot believe it that it took so long to find the solution....

I experience the same error message. Only my project runs fine locally, but not when git-pulled down to an Ubuntu VM. This is a clean pull, so there's no linked libraries.

Versions

@angular/cli: 1.0.0-beta.32.3
node: 7.5.0
os: linux x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

Error

> ng "build"

 86% hashingcrypto.js:74
  this._handle.update(data, encoding);
               ^

TypeError: Data must be a string or a buffer
    at Hash.update (crypto.js:74:16)
    at HarmonyExportImportedSpecifierDependency.updateHash (/home/gymsystems/gymsystems/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js:144:8)
    at /home/gymsystems/gymsystems/node_modules/webpack/lib/DependenciesBlock.js:33:5
    at Array.forEach (native)
    at NormalModule.DependenciesBlock.updateHash (/home/gymsystems/gymsystems/node_modules/webpack/lib/DependenciesBlock.js:32:20)
    at NormalModule.Module.updateHash (/home/gymsystems/gymsystems/node_modules/webpack/lib/Module.js:162:41)
    at NormalModule.updateHash (/home/gymsystems/gymsystems/node_modules/webpack/lib/NormalModule.js:327:30)
    at modules.forEach.m (/home/gymsystems/gymsystems/node_modules/webpack/lib/Chunk.js:253:31)
    at Array.forEach (native)
    at Chunk.updateHash (/home/gymsystems/gymsystems/node_modules/webpack/lib/Chunk.js:253:16)
    at Compilation.createHash (/home/gymsystems/gymsystems/node_modules/webpack/lib/Compilation.js:1121:10)
    at sealPart2 (/home/gymsystems/gymsystems/node_modules/webpack/lib/Compilation.js:605:9)
    at next (/home/gymsystems/gymsystems/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.<anonymous> (/home/gymsystems/gymsystems/node_modules/webpack/lib/ProgressPlugin.js:110:5)
    at next (/home/gymsystems/gymsystems/node_modules/tapable/lib/Tapable.js:140:14)
    at ExtractTextPlugin.<anonymous> (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/index.js:305:5)
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:359:16
    at iteratorCallback (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:935:13)
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:843:16
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/index.js:289:6
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:359:16
    at iteratorCallback (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:935:13)
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:843:16
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/index.js:286:13
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:940:9)
    at eachOf (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:990:5)
    at Object.eachLimit (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3089:3)
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/index.js:260:11
    at /home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:940:9)
    at eachOf (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:990:5)
    at Object.eachLimit (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (/home/gymsystems/gymsystems/node_modules/extract-text-webpack-plugin/index.js:257:10)
    at Compilation.applyPluginsAsyncSeries (/home/gymsystems/gymsystems/node_modules/tapable/lib/Tapable.js:142:13)
    at Compilation.seal (/home/gymsystems/gymsystems/node_modules/webpack/lib/Compilation.js:570:8)
    at /home/gymsystems/gymsystems/node_modules/webpack/lib/Compiler.js:474:16
    at /home/gymsystems/gymsystems/node_modules/tapable/lib/Tapable.js:225:11
    at _addModuleChain (/home/gymsystems/gymsystems/node_modules/webpack/lib/Compilation.js:472:11)
    at processModuleDependencies.err (/home/gymsystems/gymsystems/node_modules/webpack/lib/Compilation.js:443:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Found the culprit.

index.ts

export * from './file'
export * from './file2'

file.ts

import { File2 } from '.'; // Reads from index.ts

This caused some kind of recursion which Windows allowed, but Ubuntu didn't.

Hi all, see https://github.com/webpack/webpack/issues/4072 and the comment from @Toub, https://github.com/webpack/webpack/issues/4072#issuecomment-278626604, on how to add some logging info to help you find the culprit of your error.

I got this error: crypto.js:74
this._handle.update(data, encoding);

My code had a type-o. Double check it.

I hit the same error message. In my case, the problem was due to a typescript compile error.

I found useful to troubleshoot is to run tsc - this produced a meaningful typescript error rather than the "Data must be a string or a buffer" one raised by webpack

I have the same problem, I solve it with this issue 4072

I think you have deleted service file and forgot to remove from import service export * from "./_service/index"

I meet the same error message. In my case. it was DeletedModule not the HarmonyExportImportedSpecifierDependency moodule. I upgrade my webpack1.X to webpack3.x

here's my package.json

json "autoprefixer": "^6.6.0", "babel": "^6.5.2", "babel-core": "^6.21.0", "babel-jest": "^6.0.1", "babel-loader": "^7.1.2", "babel-preset-env": "^1.6.1", "babel-preset-es2015": "^6.18.0", "babel-preset-react": "^6.16.0", "babel-preset-stage-1": "^6.24.1", "babel-preset-stage-3": "^6.24.1", "copy-webpack-plugin": "^4.0.1", "cross-env": "^3.2.4", "css-loader": "^0.26.1", "enzyme": "^2.9.1", "enzyme-to-json": "^2.0.0", "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^0.9.0", "ftp": "^0.3.10", "glob": "^7.1.1", "html-webpack-plugin": "^2.24.1", "image-webpack-loader": "^3.3.0", "jest": "^21.1.0", "jest-cli": "^21.1.0", "less": "^2.7.2", "less-loader": "^2.2.3", "node-sass": "^4.0.0", "postcss-loader": "^1.3.3", "precss": "^1.4.0", "react-addons-test-utils": "^15.0.0-rc.2", "react-hot-loader": "^1.3.1", "sass-loader": "^6.0.6", "style-loader": "^0.13.1", "uglifyjs-webpack-plugin": "^1.1.4", "url-loader": "^0.5.9", "webpack": "^3.10.0", "webpack-dashboard": "^0.2.0", "webpack-dev-server": "^2.9.6"

Error
```` javascript
crypto.js:67
this._handle.update(data, encoding);
^

TypeError: Data must be a string or a buffer
at TypeError (native)
at Hash.update (crypto.js:67:16)
at DelegatedModule.updateHash (C:\Github\d-vault\webui\node_modules\webpack\lib\DelegatedModule.js:93:8)
at _modules.forEach.m (C:\Github\d-vault\webui\node_modules\webpack\lib\Chunk.js:356:32)
at SortableSet.forEach (native)
at Chunk.updateHash (C:\Github\d-vault\webui\node_modules\webpack\lib\Chunk.js:356:17)
at Compilation.createHash (C:\Github\d-vault\webui\node_modules\webpack\lib\Compilation.js:1334:10)
at sealPart2 (C:\Github\d-vault\webui\node_modules\webpack\lib\Compilation.js:645:9)
at next (C:\Github\d-vault\webui\node_modules\tapable\lib\Tapable.js:202:11)
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\dist\index.js:244:13
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:473:16
at iteratorCallback (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1050:13)
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:958:16
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\dist\index.js:227:15
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:473:16
at iteratorCallback (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1050:13)
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:958:16
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\dist\index.js:224:22
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3096:16
at eachOfArrayLike (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1055:9)
at eachOf (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1103:5)
at Object.eachLimit (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3158:5)
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\dist\index.js:189:29
at C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3096:16
at eachOfArrayLike (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1055:9)
at eachOf (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1103:5)
at Object.eachLimit (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3158:5)
at Compilation. (C:\Github\d-vault\webui\node_modules\extract-text-webpack-plugin\dist\index.js:184:27)
````

i got the same error but when i try to update node version also error message change, i got this when using stable v9
internal/crypto/hash.js:53
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'data',
^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, TypedArray, or DataView
at Hash.update (internal/crypto/hash.js:53:11)
at sha1 (/home/dontito/NodeORMs/node_modules/mysql2/lib/auth_41.js:30:8)
at Object.token [as calculateToken] (/home/dontito/NodeORMs/node_modules/mysql2/lib/auth_41.js:64:16)
at new HandshakeResponse (/home/dontito/NodeORMs/node_modules/mysql2/lib/packets/handshake_response.js:28:24)
at ClientHandshake.sendCredentials (/home/dontito/NodeORMs/node_modules/mysql2/lib/commands/client_handshake.js:51:27)
at ClientHandshake.handshakeInit (/home/dontito/NodeORMs/node_modules/mysql2/lib/commands/client_handshake.js:142:10)
at ClientHandshake.Command.execute (/home/dontito/NodeORMs/node_modules/mysql2/lib/commands/command.js:40:20)
at Connection.handlePacket (/home/dontito/NodeORMs/node_modules/mysql2/lib/connection.js:502:28)
at PacketParser.onPacket (/home/dontito/NodeORMs/node_modules/mysql2/lib/connection.js:81:16)
at PacketParser.executeStart (/home/dontito/NodeORMs/node_modules/mysql2/lib/packet_parser.js:77:14)
at Socket. (/home/dontito/NodeORMs/node_modules/mysql2/lib/connection.js:89:29)
at Socket.emit (events.js:127:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onread (net.js:590:20)

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings