Yarn: Cannot find module 'stringstream'

Created on 13 Oct 2016  ยท  16Comments  ยท  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?
Bug
What is the current behavior?
While install phantomjs there is a delay and fails with error : Cannot find module 'stringstream'
If the current behavior is a bug, please provide the steps to reproduce.
I am using this package.json https://github.com/reflexdemon/ng-gulp/blob/master/package.json
While trying to delete the node_modules folder and try to do the yarn install I get the following issue

$ yarn install
yarn install v0.15.1
warning [email protected]: Dependency "url" listed in "devDependencies" is the name of a built-in module
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
warning [email protected]: The engine "rhino" appears to be invalid.
warning [email protected]: The engine "rhino" appears to be invalid.
[3/4] ๐Ÿ”—  Linking dependencies...
warning Unmet peer dependency "chai@*".
warning Unmet peer dependency "mocha@*".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
[1/2] โ  ws
[2/2] โ  phantomjs
[-/2] โ  waiting...
[-/2] โ  waiting...
error /Users/loginuser/Development/Workspace/local/ng-gulp/node_modules/phantomjs: Command failed.
Exit code: 1
Command: sh
Arguments: -c node install.js
Directory: /Users/loginuser/Development/Workspace/local/ng-gulp/node_modules/phantomjs
Output:
module.js:457
    throw err;
    ^

Error: Cannot find module 'stringstream'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/loginuser/Development/Workspace/local/ng-gulp/node_modules/phantomjs/node_modules/request/request.js:14:20)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at SpawnError (/Users/loginuser/.yarn/lib/errors.js:18:1)
    at ChildProcess.proc.on.code (/Users/loginuser/.yarn/lib/util/child.js:107:15)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:493:12)
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the expected behavior?
I see errors only on the first run. To my surprise while trying to run yarn install for the second time it completes successfully. This looks like a caching issue on the yarn that needs to be checked.

$ yarn install
yarn install v0.15.1
warning [email protected]: Dependency "url" listed in "devDependencies" is the name of a built-in module
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
warning [email protected]: The engine "rhino" appears to be invalid.
warning [email protected]: The engine "rhino" appears to be invalid.
[3/4] ๐Ÿ”—  Linking dependencies...
warning Unmet peer dependency "chai@*".
warning Unmet peer dependency "mocha@*".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
โœจ  Done in 4.03s.

Please mention your node.js, yarn and operating system version.

$ node -v
v6.5.0
$ npm -v
3.10.3
$ yarn -v
yarn install v0.15.1
warning [email protected]: Dependency "url" listed in "devDependencies" is the name of a built-in module
success Already up-to-date.
โœจ  Done in 0.12s.
System Version: OS X 10.10.5 (14F27)
Kernel Version: Darwin 14.5.0

Most helpful comment

We were able to fix this by updating our package that had phantomjs as a dependency.

Previously, we were using grunt-contrib-jasmine 0.9.2, which depended on grunt-lib-phantomjs ^0.7.1. , which is dependent on phantomjs ^1.9.15

We upgraded to grunt-contrib-jasmine [email protected] -> grunt-lib-phantomjs ^1.0.0 -> phantomjs-prebuilt: ^2.1.3

So, perhaps the old phantomjs package doesn't play nicely with yarn (they changed the name to phantomjs-prebuilt at some point).

Hopefully this helps some of you.

All 16 comments

There is something peculiar going on with phantomjs and yarn. On a clean project I do yarn add phantomjs and it works and then do yarn outdated and I get

yarn outdated v0.15.1
Package   Current          Wanted Latest
phantomjs 2.1.7+deprecated 2.1.7  2.1.7
โœจ  Done in 0.68s.

I'm seeing a similar issue with yarn global add strongloop. Please note npm i -g strongloop is fine.

yarn global add strongloop
yarn global v0.15.1
warning No license field
[1/4] ๐Ÿ”  Resolving packages...
warning strongloop > node-inspector > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning strongloop > strong-arc > strong-mesh-client > browserify > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
[2/4] ๐Ÿšš  Fetching packages...
warning [email protected]: The engine "rhino" appears to be invalid.
warning [email protected]: The engine "rhino" appears to be invalid.
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
[-/5] โ   waiting...
[2/5] โ   ws
[3/5] โ   strong-agent
[4/5] โ   strong-mesh-client
error /Users/rfeng/.yarn-cache/.global/node_modules/strong-mesh-client: Command failed.
Exit code: 1
Command: sh
Arguments: -c node proxy/build-client.js
Directory: /Users/rfeng/.yarn-cache/.global/node_modules/strong-mesh-client
Output:
module.js:471
    throw err;
    ^

Error: Cannot find module 'JSONStream'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/rfeng/.yarn-cache/.global/node_modules/browser-pack/index.js:1:80)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at SpawnError (/Users/rfeng/.nvm/versions/node/v6.8.0/lib/node_modules/yarn/lib/errors.js:18:1)
    at ChildProcess.proc.on.code (/Users/rfeng/.nvm/versions/node/v6.8.0/lib/node_modules/yarn/lib/util/child.js:107:15)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:498:12)
info Visit http://yarnpkg.com/en/docs/cli/global for documentation about this command.

Scratch that - looks like the package is still missing.

FWIW, I'm getting the exact same issue described in the original issue and running yarn install a second time seems to install correctly.

We were able to fix this by updating our package that had phantomjs as a dependency.

Previously, we were using grunt-contrib-jasmine 0.9.2, which depended on grunt-lib-phantomjs ^0.7.1. , which is dependent on phantomjs ^1.9.15

We upgraded to grunt-contrib-jasmine [email protected] -> grunt-lib-phantomjs ^1.0.0 -> phantomjs-prebuilt: ^2.1.3

So, perhaps the old phantomjs package doesn't play nicely with yarn (they changed the name to phantomjs-prebuilt at some point).

Hopefully this helps some of you.

Ran into the same issue
We have different dependencies and updating them didn't work
Not ideal, but manually adding stringstream to the project's devDependencies worked

PhantomJS 1.9 was released over 3 years ago. yarn installs the latest versions of PhantomJS fine via phantomjs-prebuilt. Because the underlying rendering engine in Phantom would be much newer in the latest releases, you can expect the renders to be more compatible as well.

If you are running into this issue, please take it as opportunity to modernize your dependency chain, or encourage the upstream modules that you use to modernize _their_ dependency chain.

Yes, ideally the yarn project could install this old module since npm does, but there are also more interesting projects to work on then creating compatibility with a rather outdated module which has a newer version published that doesn't have problems.

Edit: Actually, upgrading to the newest version of yarn seems to fix this for me!

@markstos I'm seeing this problem with the latest version of phantomjs-prebuilt.

@kaicataldo, great. It just passed for me with yarn 0.15.1 and phantom-prebuilt 2.1.0.

Works great now!!!

$ rm -rf node_modules

$ yarn
yarn install v0.16.0
warning [email protected]: Dependency "url" listed in "devDependencies" is the name of a built-in module
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning Unmet peer dependency "chai@*".
warning Unmet peer dependency "mocha@*".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
...


โœจ  Done in 17.16s.
``

This can be closed now.

I confirmed even old versions of phantomjs can now be installed as well:

   yarn add [email protected]

If if you can't or don't want to upgrade to phantomjs-prebuilt (using Phantom 2.0), it seems the latest version of the 1.x series works as well.

Closing as everyone reports this is working now.

I had this problem after installing yarn locally with npm

$ npm install yarn
$ ./node_modules/.bin/yarn add express --save --verbose

Yarn, in the "removing unused files" phase, was simply deleting its own files, therefore resulting in File not found errors and being able to finish my tasks ๐Ÿ™„.

Installing yarn with a -g option (or using any other method listed on the yarn website), solved my issue.

I am having this problem, using exceljs https://www.npmjs.com/package/exceljs
this is the error I got

module.js:472
    throw err;
    ^
Error: Cannot find module './doc/workbook'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

@juliocanares You are different a problem. You are trying to install a different package than the other people here and are having a problem finding a different module. This ticket was about stringstream. You are having trouble finding a module internal to exceljs. If you think that's a bug in yarn, you should open a new issue.

thanks @markstos I will open a new issue ๐Ÿ‘

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebmck picture sebmck  ยท  3Comments

FLGMwt picture FLGMwt  ยท  3Comments

catkins picture catkins  ยท  3Comments

chiedo picture chiedo  ยท  3Comments

victornoel picture victornoel  ยท  3Comments