2017-04-17 15 views
0

親ディレクトリに保存されている共有ノードモジュールを使用します。私は、次のフォルダ構造があります。webpackで親ディレクトリの共有ノードモジュールを使用する方法

  • 親ディレクトリに
    • node_modules
    • を会社
      • serverless.yml
      • handler.js
      • webpack.config

私はwebpackを使用してパッケージを作成し、aws-lamdaにアップロードする必要があります。しかし、webpackはノードモジュールを探しています。しかし、次のエラーが表示されます。

Overriding the webpack directory in serverless-webpack since it uses v1 version of webpack... 
cp: cannot stat 'node_modules/webpack': No such file or directory 

webpack.configを親ディレクトリのnode_modulesに設定するにはどうすればよいですか。

+0

ned npmは何のエラーも起こさずにインストールしますか? – Gntem

+0

親ディレクトリにある共有ノードモジュールを使いたい – suku

+0

webpackエラーのようには見えませんが、存在しないファイルを 'cp'しようとするシェルスクリプトエラーのようです。またwebpackは、他に設定されていない限り、現在のディレクトリの 'node_modules'に見つからなかった場合、親' node_modules'を喜んで調べます。実行しているスクリプトを表示できますか? –

答えて

0

NodeJSのドキュメントを読む場合、パッケージに同じ依存関係が必要な場合でもローカルのnode_modulesフォルダを使用することを強くお勧めします。

https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders

代わりにあなたがNODE_PATHで作業することができ、必要に通知が最初のWebPACKを解決する多くのモジュールを公開しているので、他のフォルダに探し始めるので、ローカルnode_modules

If the NODE_PATH environment variable is set to a colon-delimited list of absolute paths, then Node.js will search those paths for modules if they are not found elsewhere. (Note: On Windows, NODE_PATH is delimited by semicolons instead of colons.)

を削除しようとするローカルnode_modulesになりますオプションhttps://webpack.github.io/docs/resolving.html

Resolving a module path For resolving a module Resolve first gathers all search directories for modules from Webpack’s context directory. This process is similar to the node.js resolving process, but the search directories are configurable with the configuration option resolve.modulesDirectories. In addition to this the directories in the configuration option resolve.root are prepended, and directories in the configuration option resolve.fallback are appended.

関連する問題