2015-11-17 92 views
1

我的所有節點模塊都在C:/ Users/user/AppData/Roaming/npm/node_modules path。然後,我試着將包含babel和babel-presets的node_modules包含在我的腳本webpack中。Node_modules在另一個文件夾中

webpack.config.js

module.exports = { 
    context: './scripts', 
    entry: ['./main', './2.jsx'], 
    output: { 
     path: '../scripts', 
     filename: 'bundle.js', 
    }, 
    resolve: { 
     modulesDirectories: ['C:/Users/user/AppData/Roaming/npm/node_modules'] 
    }, 
    resolveLoader: { 
     root: 'C:/Users/user/AppData/Roaming/npm/node_modules' 
    }, 
    module: { 
     loaders: [{ 
      test: /\.jsx?$/, 
      loader: 'babel-loader', 
      include: 'C:/Users/user/AppData/Roaming/npm/node_modules', 
      exclude: /(node_modules|bower_components)/, 
      query: { 
       presets: ['es2015', 'react'] 
      } 
     }], 
    }, 
}; 

但巴貝爾並沒有看到預設ES2015。並預設反應我也覺得。

webpack命令retunrs這樣的:

ERROR in ../main.js Module build failed: Error: Couldn't find preset "es2015" 
    at OptionManager.mergePresets (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\options\option-manager.js:329:17) 
    at OptionManager.mergeOptions (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\options\option-manager.js:289:12) 
    at OptionManager.init (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\options\option-manager.js:414:10) 
    at File.initOptions (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\index.js:191:75) 
    at new File (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\index.js:122:22) 
    at Pipeline.transform (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\pipeline.js:42:16) 
    at transpile (C:\Users\user\AppData\Roaming\npm\node_modules\babel-loader\index.js:14:22) 
    at Object.module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\babel-loader\index.js:83:14) @ multi main 

請幫助。錯誤在哪裏?

+0

爲什麼不把它們添加到本地項目中? npm install XXXX --save-dev? –

+0

我試圖用一個node_modules文件夾找到許多項目的解決方案 – Ifgeny87

+3

這不是正確的方法,每個節點項目都應該有自己的node_modules文件夾,並且所有模塊都聲明爲package.json文件。 –

回答

1

找到解決方案。

npm link <pkg>

其添加鏈接模塊。

相關問題