私はノードモジュールとしてリリースされているjavascriptプロジェクトを持っています。自己をnpmのノードモジュールとして扱います
:このプロジェクト内の他のファイルをインポートするには、ルートパスとしてモジュール名を使用して// <this_module_path>/action/foo.js
import execution from './execution';
import types from '../types';
とも:いくつかの理由から、私はこのプロジェクト内の他のファイルをインポートするには、相対パスを使用して、いくつかのソースコードを持っています
// <this_module_path>/action/doSomething.js // Using module name to import // equals to import './helpers.js' in this case (in the same folder) import executionHelpers from 'this-module/action/helpers.js'; // equals to import '../types/helpers' in this case import typeHelpers from 'this-module/types/helpers.js';
相対パスではなくモジュール名を使用して他のプロジェクトファイルをインポートするにはどうすればよいですか?
Babelを使用してコードを翻訳し、 'import'構文をCommonJSに変換していますか? – bman