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

Not working with pnpm #2855

Closed
1 task done
vjpr opened this issue Aug 27, 2017 · 14 comments
Closed
1 task done

Not working with pnpm #2855

vjpr opened this issue Aug 27, 2017 · 14 comments

Comments

@vjpr
Copy link

vjpr commented Aug 27, 2017

pnpm is an alternative package manager.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Should work.

Current Behavior

npm run build

> vwp@1.0.0 build /Users/Vaughan/dev-live/vwp
> next build

> Failed to build on /var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/f445f6d8-80e8-4d8d-8946-d62056f4ddb7
{ Error: ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry
Module not found: Error: Can't resolve '../../../../../../../../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js' in '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages'
resolve '../../../../../../../../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js' in '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages'
  using description file: /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/package.json (relative path: ./dist/pages)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/package.json (relative path: ./dist/pages)
    using description file: /Users/Vaughan/dev-live/vwp/package.json (relative path: ./.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.json doesn't exist
      as directory
        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js doesn't exist
[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js]
[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.js]
[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.json]
[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js]
 @ ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry 3:17-118
 @ multi ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry
    at /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/build/index.js:182:21
    at emitRecords.err (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/Compiler.js:269:13)
    at Compiler.emitRecords (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/Compiler.js:375:38)
    at emitAssets.err (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/Compiler.js:368:12)
    at next (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/tapable/0.2.8/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/tapable/0.2.8/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/Compiler.js:365:9)
    at require.forEach.err (/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/webpack/3.3.0/node_modules/webpack/lib/Compiler.js:360:15)
  errors:
   [ './node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry\nModule not found: Error: Can\'t resolve \'../../../../../../../../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js\' in \'/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages\'\nresolve \'../../../../../../../../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js\' in \'/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages\'\n  using description file: /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/package.json (relative path: ./dist/pages)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/package.json (relative path: ./dist/pages)\n    using description file: /Users/Vaughan/dev-live/vwp/package.json (relative path: ./.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js)\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.json doesn\'t exist\n      as directory\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js doesn\'t exist\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js]\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.js]\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js.json]\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/lib/error.js]\n @ ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry 3:17-118\n @ multi ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry',
     './node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_document.js?entry\nModule not found: Error: Can\'t resolve \'../../../../../../../../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js\' in \'/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages\'\nresolve \'../../../../../../../../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js\' in \'/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages\'\n  using description file: /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/package.json (relative path: ./dist/pages)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/package.json (relative path: ./dist/pages)\n    using description file: /Users/Vaughan/dev-live/vwp/package.json (relative path: ./.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js)\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js.json doesn\'t exist\n      as directory\n        /Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js doesn\'t exist\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js]\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js.js]\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js.json]\n[/Users/Vaughan/dev-live/vwp/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js]\n @ ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_document.js?entry 3:17-124\n @ multi ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_document.js?entry' ],
  warnings: [] }

Steps to Reproduce (for bugs)

  1. mkdir foo && cd foo
  2. npm init -y
  3. pnpm i react react-dom next
  4. npm run build

Context

Your Environment

Tech Version
next 3.0.6
node 8.1.2
OS macOS
browser
etc
@vjpr
Copy link
Author

vjpr commented Aug 27, 2017

Here is the tree:

tree -l
.
├── node_modules
│   ├── next -> .registry.npmjs.org/next/3.0.6/node_modules/next
│   │   ├── babel.js
│   │   ├── css.js
│   │   ├── dist
│   │   │   ├── bin
│   │   │   │   ├── next
│   │   │   │   ├── next-build
│   │   │   │   ├── next-dev
│   │   │   │   ├── next-export
│   │   │   │   ├── next-init
│   │   │   │   └── next-start
│   │   │   ├── client
│   │   │   │   ├── head-manager.js
│   │   │   │   ├── index.js
│   │   │   │   ├── next-dev.js
│   │   │   │   ├── next.js
│   │   │   │   ├── on-demand-entries-client.js
│   │   │   │   └── webpack-hot-middleware-client.js
│   │   │   ├── lib
│   │   │   │   ├── EventEmitter.js
│   │   │   │   ├── app.js
│   │   │   │   ├── css.js
│   │   │   │   ├── dynamic.js
│   │   │   │   ├── error-debug.js
│   │   │   │   ├── error.js
│   │   │   │   ├── head.js
│   │   │   │   ├── link.js
│   │   │   │   ├── p-queue.js
│   │   │   │   ├── page-loader.js
│   │   │   │   ├── prefetch.js
│   │   │   │   ├── router
│   │   │   │   │   ├── index.js
│   │   │   │   │   └── router.js
│   │   │   │   ├── shallow-equals.js
│   │   │   │   ├── side-effect.js
│   │   │   │   └── utils.js
│   │   │   ├── pages
│   │   │   │   ├── _document.js
│   │   │   │   └── _error.js
│   │   │   └── server
│   │   │       ├── build
│   │   │       │   ├── babel
│   │   │       │   │   ├── find-config.js
│   │   │       │   │   ├── plugins
│   │   │       │   │   │   └── handle-import.js
│   │   │       │   │   └── preset.js
│   │   │       │   ├── clean.js
│   │   │       │   ├── index.js
│   │   │       │   ├── loaders
│   │   │       │   │   ├── emit-file-loader.js
│   │   │       │   │   └── hot-self-accept-loader.js
│   │   │       │   ├── plugins
│   │   │       │   │   ├── combine-assets-plugin.js
│   │   │       │   │   ├── dynamic-chunks-plugin.js
│   │   │       │   │   ├── pages-plugin.js
│   │   │       │   │   ├── unlink-file-plugin.js
│   │   │       │   │   └── watch-pages-plugin.js
│   │   │       │   ├── replace.js
│   │   │       │   ├── root-module-relative-path.js
│   │   │       │   └── webpack.js
│   │   │       ├── config.js
│   │   │       ├── document.js
│   │   │       ├── export.js
│   │   │       ├── hot-reloader.js
│   │   │       ├── index.js
│   │   │       ├── next.js
│   │   │       ├── on-demand-entry-handler.js
│   │   │       ├── render.js
│   │   │       ├── require.js
│   │   │       ├── resolve.js
│   │   │       ├── router.js
│   │   │       └── utils.js
│   │   ├── document.js
│   │   ├── dynamic.js
│   │   ├── error.js
│   │   ├── head.js
│   │   ├── license.md
│   │   ├── link.js
│   │   ├── node_modules
│   │   ├── package.json
│   │   ├── prefetch.js
│   │   ├── readme.md
│   │   └── router.js
│   ├── react -> .registry.npmjs.org/react/15.6.1/node_modules/react
│   │   ├── LICENSE
│   │   ├── PATENTS
│   │   ├── README.md
│   │   ├── dist
│   │   │   ├── react-with-addons.js
│   │   │   ├── react-with-addons.min.js
│   │   │   ├── react.js
│   │   │   └── react.min.js
│   │   ├── lib
│   │   │   ├── KeyEscapeUtils.js
│   │   │   ├── LinkedStateMixin.js
│   │   │   ├── PooledClass.js
│   │   │   ├── React.js
│   │   │   ├── ReactAddonsDOMDependencies.js
│   │   │   ├── ReactAddonsDOMDependenciesUMDShim.js
│   │   │   ├── ReactBaseClasses.js
│   │   │   ├── ReactCSSTransitionGroup.js
│   │   │   ├── ReactCSSTransitionGroupChild.js
│   │   │   ├── ReactChildren.js
│   │   │   ├── ReactComponentTreeDevtool.js
│   │   │   ├── ReactComponentTreeHook.js
│   │   │   ├── ReactComponentTreeHookUMDShim.js
│   │   │   ├── ReactComponentWithPureRenderMixin.js
│   │   │   ├── ReactCurrentOwner.js
│   │   │   ├── ReactCurrentOwnerUMDShim.js
│   │   │   ├── ReactDOMFactories.js
│   │   │   ├── ReactElement.js
│   │   │   ├── ReactElementSymbol.js
│   │   │   ├── ReactElementType.js
│   │   │   ├── ReactElementValidator.js
│   │   │   ├── ReactFragment.js
│   │   │   ├── ReactLink.js
│   │   │   ├── ReactNoopUpdateQueue.js
│   │   │   ├── ReactPropTypeLocationNames.js
│   │   │   ├── ReactPropTypeLocations.js
│   │   │   ├── ReactPropTypes.js
│   │   │   ├── ReactPropTypesSecret.js
│   │   │   ├── ReactStateSetters.js
│   │   │   ├── ReactTransitionChildMapping.js
│   │   │   ├── ReactTransitionEvents.js
│   │   │   ├── ReactTransitionGroup.js
│   │   │   ├── ReactUMDEntry.js
│   │   │   ├── ReactUMDShim.js
│   │   │   ├── ReactVersion.js
│   │   │   ├── ReactWithAddons.js
│   │   │   ├── ReactWithAddonsUMDEntry.js
│   │   │   ├── canDefineProperty.js
│   │   │   ├── checkReactTypeSpec.js
│   │   │   ├── createClass.js
│   │   │   ├── deprecated.js
│   │   │   ├── flattenChildren.js
│   │   │   ├── getIteratorFn.js
│   │   │   ├── getNextDebugID.js
│   │   │   ├── getNextDebugIDUMDShim.js
│   │   │   ├── lowPriorityWarning.js
│   │   │   ├── onlyChild.js
│   │   │   ├── reactProdInvariant.js
│   │   │   ├── shallowCompare.js
│   │   │   ├── sliceChildren.js
│   │   │   ├── traverseAllChildren.js
│   │   │   └── update.js
│   │   ├── node_modules
│   │   ├── package.json
│   │   └── react.js
│   └── react-dom -> .registry.npmjs.org/react-dom/15.6.1/node_modules/react-dom
│       ├── LICENSE
│       ├── PATENTS
│       ├── README.md
│       ├── dist
│       │   ├── react-dom-server.js
│       │   ├── react-dom-server.min.js
│       │   ├── react-dom.js
│       │   └── react-dom.min.js
│       ├── index.js
│       ├── lib
│       │   ├── ARIADOMPropertyConfig.js
│       │   ├── AutoFocusUtils.js
│       │   ├── BeforeInputEventPlugin.js
│       │   ├── CSSProperty.js
│       │   ├── CSSPropertyOperations.js
│       │   ├── CallbackQueue.js
│       │   ├── ChangeEventPlugin.js
│       │   ├── DOMChildrenOperations.js
│       │   ├── DOMLazyTree.js
│       │   ├── DOMNamespaces.js
│       │   ├── DOMProperty.js
│       │   ├── DOMPropertyOperations.js
│       │   ├── Danger.js
│       │   ├── DefaultEventPluginOrder.js
│       │   ├── EnterLeaveEventPlugin.js
│       │   ├── EventConstants.js
│       │   ├── EventPluginHub.js
│       │   ├── EventPluginRegistry.js
│       │   ├── EventPluginUtils.js
│       │   ├── EventPropagators.js
│       │   ├── FallbackCompositionState.js
│       │   ├── HTMLDOMPropertyConfig.js
│       │   ├── KeyEscapeUtils.js
│       │   ├── LinkedValueUtils.js
│       │   ├── PluginModuleType.js
│       │   ├── PooledClass.js
│       │   ├── ReactBrowserEventEmitter.js
│       │   ├── ReactChildFiber.js
│       │   ├── ReactChildReconciler.js
│       │   ├── ReactComponentBrowserEnvironment.js
│       │   ├── ReactComponentEnvironment.js
│       │   ├── ReactComponentTreeTestUtils.js
│       │   ├── ReactCompositeComponent.js
│       │   ├── ReactCoroutine.js
│       │   ├── ReactDOM.js
│       │   ├── ReactDOMComponent.js
│       │   ├── ReactDOMComponentFlags.js
│       │   ├── ReactDOMComponentTree.js
│       │   ├── ReactDOMContainerInfo.js
│       │   ├── ReactDOMEmptyComponent.js
│       │   ├── ReactDOMFeatureFlags.js
│       │   ├── ReactDOMFiber.js
│       │   ├── ReactDOMIDOperations.js
│       │   ├── ReactDOMInput.js
│       │   ├── ReactDOMInvalidARIAHook.js
│       │   ├── ReactDOMNullInputValuePropHook.js
│       │   ├── ReactDOMOption.js
│       │   ├── ReactDOMSelect.js
│       │   ├── ReactDOMSelection.js
│       │   ├── ReactDOMServer.js
│       │   ├── ReactDOMServerUMDEntry.js
│       │   ├── ReactDOMTextComponent.js
│       │   ├── ReactDOMTextarea.js
│       │   ├── ReactDOMTreeTraversal.js
│       │   ├── ReactDOMUMDEntry.js
│       │   ├── ReactDOMUnknownPropertyHook.js
│       │   ├── ReactDebugTool.js
│       │   ├── ReactDefaultBatchingStrategy.js
│       │   ├── ReactDefaultInjection.js
│       │   ├── ReactElementSymbol.js
│       │   ├── ReactEmptyComponent.js
│       │   ├── ReactErrorUtils.js
│       │   ├── ReactEventEmitterMixin.js
│       │   ├── ReactEventListener.js
│       │   ├── ReactFeatureFlags.js
│       │   ├── ReactFiber.js
│       │   ├── ReactFiberBeginWork.js
│       │   ├── ReactFiberCommitWork.js
│       │   ├── ReactFiberCompleteWork.js
│       │   ├── ReactFiberReconciler.js
│       │   ├── ReactFiberRoot.js
│       │   ├── ReactFiberScheduler.js
│       │   ├── ReactFiberUpdateQueue.js
│       │   ├── ReactHostComponent.js
│       │   ├── ReactHostOperationHistoryHook.js
│       │   ├── ReactInjection.js
│       │   ├── ReactInputSelection.js
│       │   ├── ReactInstanceMap.js
│       │   ├── ReactInstanceType.js
│       │   ├── ReactInstrumentation.js
│       │   ├── ReactInvalidSetStateWarningHook.js
│       │   ├── ReactMarkupChecksum.js
│       │   ├── ReactMount.js
│       │   ├── ReactMultiChild.js
│       │   ├── ReactMultiChildUpdateTypes.js
│       │   ├── ReactNodeTypes.js
│       │   ├── ReactOwner.js
│       │   ├── ReactPerf.js
│       │   ├── ReactPriorityLevel.js
│       │   ├── ReactPropTypeLocationNames.js
│       │   ├── ReactPropTypeLocations.js
│       │   ├── ReactPropTypesSecret.js
│       │   ├── ReactReconcileTransaction.js
│       │   ├── ReactReconciler.js
│       │   ├── ReactRef.js
│       │   ├── ReactReifiedYield.js
│       │   ├── ReactServerBatchingStrategy.js
│       │   ├── ReactServerRendering.js
│       │   ├── ReactServerRenderingTransaction.js
│       │   ├── ReactServerUpdateQueue.js
│       │   ├── ReactShallowRenderer.js
│       │   ├── ReactSimpleEmptyComponent.js
│       │   ├── ReactSyntheticEventType.js
│       │   ├── ReactTestReconcileTransaction.js
│       │   ├── ReactTestUtils.js
│       │   ├── ReactTypeOfWork.js
│       │   ├── ReactTypes.js
│       │   ├── ReactUpdateQueue.js
│       │   ├── ReactUpdates.js
│       │   ├── ReactVersion.js
│       │   ├── ResponderEventPlugin.js
│       │   ├── ResponderSyntheticEvent.js
│       │   ├── ResponderTouchHistoryStore.js
│       │   ├── SVGDOMPropertyConfig.js
│       │   ├── SelectEventPlugin.js
│       │   ├── SimpleEventPlugin.js
│       │   ├── SyntheticAnimationEvent.js
│       │   ├── SyntheticClipboardEvent.js
│       │   ├── SyntheticCompositionEvent.js
│       │   ├── SyntheticDragEvent.js
│       │   ├── SyntheticEvent.js
│       │   ├── SyntheticFocusEvent.js
│       │   ├── SyntheticInputEvent.js
│       │   ├── SyntheticKeyboardEvent.js
│       │   ├── SyntheticMouseEvent.js
│       │   ├── SyntheticTouchEvent.js
│       │   ├── SyntheticTransitionEvent.js
│       │   ├── SyntheticUIEvent.js
│       │   ├── SyntheticWheelEvent.js
│       │   ├── TapEventPlugin.js
│       │   ├── TouchHistoryMath.js
│       │   ├── Transaction.js
│       │   ├── ViewportMetrics.js
│       │   ├── accumulate.js
│       │   ├── accumulateInto.js
│       │   ├── adler32.js
│       │   ├── canDefineProperty.js
│       │   ├── checkReactTypeSpec.js
│       │   ├── createMicrosoftUnsafeLocalFunction.js
│       │   ├── dangerousStyleValue.js
│       │   ├── deprecated.js
│       │   ├── escapeTextContentForBrowser.js
│       │   ├── findDOMNode.js
│       │   ├── flattenChildren.js
│       │   ├── forEachAccumulated.js
│       │   ├── getEventCharCode.js
│       │   ├── getEventKey.js
│       │   ├── getEventModifierState.js
│       │   ├── getEventTarget.js
│       │   ├── getHostComponentFromComposite.js
│       │   ├── getIteratorFn.js
│       │   ├── getNodeForCharacterOffset.js
│       │   ├── getTestDocument.js
│       │   ├── getTextContentAccessor.js
│       │   ├── getVendorPrefixedEventName.js
│       │   ├── inputValueTracking.js
│       │   ├── instantiateReactComponent.js
│       │   ├── isEventSupported.js
│       │   ├── isTextInputElement.js
│       │   ├── lowPriorityWarning.js
│       │   ├── quoteAttributeValueForBrowser.js
│       │   ├── reactComponentExpect.js
│       │   ├── reactProdInvariant.js
│       │   ├── renderSubtreeIntoContainer.js
│       │   ├── setInnerHTML.js
│       │   ├── setTextContent.js
│       │   ├── shouldUpdateReactComponent.js
│       │   ├── traverseAllChildren.js
│       │   └── validateDOMNesting.js
│       ├── node_modules
│       ├── package.json
│       ├── server.js
│       └── test-utils.js
├── package.json
├── pages
│   └── index.js
└── shrinkwrap.yaml

@vjpr
Copy link
Author

vjpr commented Aug 27, 2017

Seems that if I npm link to a local clone of next.js it works.

@markozxuu
Copy link
Contributor

Hi, I could further detail your problem.

@arunoda
Copy link
Contributor

arunoda commented Aug 28, 2017

I've tried pnpm with some other packages. Sometimes it works and sometimes it wont.
We don't do anything specific with NPM and modules.
So, this is not something we can handle.

@arunoda arunoda closed this as completed Aug 28, 2017
@arunoda
Copy link
Contributor

arunoda commented Aug 28, 2017

But may be we could find some workaround. If there's something specific we need to do in the core, feel free to send a PR.

@vjpr
Copy link
Author

vjpr commented Oct 24, 2017

Related #2846

@vjpr
Copy link
Author

vjpr commented Oct 24, 2017

Seems that if I npm link to a local clone of next.js it works.

npm linked

{ entries:
   { 'main.js':
      [ '/Users/Vaughan/dev-live/next.js/dist/client/webpack-hot-middleware-client',
        '/Users/Vaughan/dev-live/next.js/dist/client/on-demand-entries-client',
        '/Users/Vaughan/dev-live/next.js/dist/client/next-dev.js' ],
     'bundles/pages/_document.js': [ './pages/_document.js?entry' ],
     'bundles/pages/_error.js': [ '/Users/Vaughan/dev-live/next.js/dist/pages/_error.js?entry' ] } }

pnpm node_modules

entries { 'main.js':
   [ '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/client/webpack-hot-middleware-client',
     '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/client/on-demand-entries-client',
     '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/client/next-dev.js' ],
  'bundles/pages/_document.js': [ './pages/_document.js?entry' ],
  'bundles/pages/_error.js': [ '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry' ] }

Both modules its saying its missing are there, and the _error is absolute so it can't be a relative path issue.

Maybe the files are failing to compile...the trouble is there is not error messages, and it doesn't happen when npm linked so I have to work with the transpiled babel code directly from node_modules (no sources are packaged) :S

_error.js

module.exports = require('next/error')

So the error messages are silenced by default...this is really bad...I will file a bug against this.

Had to add to next.config.js:

  webpackDevMiddleware: (config) => {
    config.quiet = false
    return config
  },

Now I see the errors!

ERROR in multi ./pages/_document.js?entry
Module not found: Error: Can't resolve 'babel-loader' in '/Users/Vaughan/dev-live/vwp'
 @ multi ./pages/_document.js?entry

ERROR in multi ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry
Module not found: Error: Can't resolve 'babel-loader' in '/Users/Vaughan/dev-live/vwp'
 @ multi ./node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/pages/_error.js?entry

Now my issue is next/error path resolution...it is currently being rewritten like so:

module.exports = require('../../../../../../../../../../node_modules/next/dist/lib/error');

Something to note is that there is no error when removing the babel-loader from webpack.js by commenting:

//presets: [require.resolve('./babel/preset')]

So the babel presets must be the cause I would guess.

But then a bunch of other errors popup all over the place.


There seems to be three places that the babel-plugin-module-resolver is used in webpack.js. I don't quite understand how it is being used.

@vjpr
Copy link
Author

vjpr commented Oct 24, 2017

@arunoda Could you provide any assistance with resolving this, or perhaps point us in the right direction?

I feel like there will be a single line change somewhere that will resolve this, but I cannot find it.

I'm guessing its something to do with root-module-relative-path at the moment...

Basically the paths will be:

/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js

instead of

/Users/Vaughan/dev-live/vwp/node_modules/next/dist/server/document.js

If I run babel pages/_document.js I get paths like this in pages/_document:

var _document = require('../.registry.npmjs.org/next/3.0.6/node_modules/next/dist/server/document.js');`

@vjpr
Copy link
Author

vjpr commented Oct 24, 2017

Okay so looks like it is babel-plugin-module-resolver or root-module-relative-path.js causing issues.

Using npm I see:

var _document = require("next/dist/server/document.js");

With pnpm I see:

var _document = require("../.registry.npmjs.org/next/4.1.3/node_modules/next/dist/server/document.js");

@vjpr
Copy link
Author

vjpr commented Oct 24, 2017

So I think I was handicapping myself when playing around with the settings.

cacheDirectory is set to true in mainBabelOptions and also in the babel-loader.

https://github.com/babel/babel-loader#options

This cannot be overridden by passing in BABEL_DISABLE_CACHE=1 at the command-line.

the loader will use the default cache directory in node_modules/.cache/babel-loader or fallback to the default OS temporary file directory if no node_modules folder could be found in any root directory.

I could not see any temp dirs and I disabled the setting so I didn't think there was a cache, but it was hiding in node_modules/.cache!

@vjpr
Copy link
Author

vjpr commented Oct 25, 2017

Fix

next.config.js

const dirResolve = require('dir-resolve')
module.exports = {
  webpack: (config, {dev}) => {
    useCustomPresetForPagesBabelLoader(config)
  }
}
function useCustomPresetForPagesBabelLoader(config) {
  // node_modules/next/dist/pages
  const nextDistPagesBabelLoader = config.module.rules.find(
    ({loader, include}) =>
      loader === 'babel-loader' && include === dirResolve('next/dist/pages'),
  )
  nextDistPagesBabelLoader.options.presets = [require.resolve('./babel-preset-next-pnpm')]

}

babel-preset-next-pnpm

Make a duplicate of next/babel, and replace the aliases with their resolved paths (and don't follow symlinks - don't use realpath).

E.g.

[require.resolve('babel-plugin-module-resolver'),
    {
        alias: {
            ...
            'next/link': 'next/dist/lib/link'
            ...
    }
]

Not sure if this will break things for production deploys, I haven't checked.

I will look to publish this preset later.

@debanjanbasu
Copy link

Can you publish the babel-preset to npmjs please? It would really help.

@debanjanbasu
Copy link

Also a simple documentation for this fix? It is really critical for my project.
I have identified that at the moment Google Cloud Functions seem to use pnpm under the hood, or something similar.

@lock
Copy link

lock bot commented May 10, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants