質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Riot.js

Riot.jsは、React.jsに似たコンポーネント指向なJSフレームワークです。非常に軽量であり、コンポーネントで設計しやすいといったメリットがあります。また、MVCのように分割できることも特徴です。

Q&A

0回答

2545閲覧

rollupでerror: path is not definedが出る

IsseiMorita

総合スコア23

Riot.js

Riot.jsは、React.jsに似たコンポーネント指向なJSフレームワークです。非常に軽量であり、コンポーネントで設計しやすいといったメリットがあります。また、MVCのように分割できることも特徴です。

0グッド

0クリップ

投稿2017/01/30 12:00

###前提・実現したいこと
riot.jsをrollupでコンパイルしていたところ、次のエラーが起きてしまい、困っています。
直し方を知っていたら、教えてください。
###エラーメッセージ

preferring built-in module 'path' over local alternative at '/Users/morit a1/Desktop/riot_timetable/node_modules/path/path.js', pass 'preferBuiltin s: false' to disable this behavior or 'preferBuiltins: true' to disable t his warning preferring built-in module 'path' over local alternative at '/Users/morit a1/Desktop/riot_timetable/node_modules/path/path.js', pass 'preferBuiltin s: false' to disable this behavior or 'preferBuiltins: true' to disable t his warning ⚠ 'path' is imported by node_modules/riot-router/node_modules/riot/lib /server/index.js, but could not be resolved – treating it as an external dependency https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as- external-dependency ⚠ 'fs' is imported by node_modules/riot-router/node_modules/riot/lib/s erver/index.js, but could not be resolved – treating it as an external de pendency https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as- external-dependency ⚠ 'module' is imported by node_modules/riot-router/node_modules/riot/l ib/server/index.js, but could not be resolved – treating it as an externa l dependency https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as- external-dependency preferring built-in module 'path' over local alternative at '/Users/morit a1/Desktop/riot_timetable/node_modules/path/path.js', pass 'preferBuiltin s: false' to disable this behavior or 'preferBuiltins: true' to disable t his warning preferring built-in module 'path' over local alternative at '/Users/morit a1/Desktop/riot_timetable/node_modules/path/path.js', pass 'preferBuiltin s: false' to disable this behavior or 'preferBuiltins: true' to disable t his warning preferring built-in module 'path' over local alternative at '/Users/morit a1/Desktop/riot_timetable/node_modules/path/path.js', pass 'preferBuiltin s: false' to disable this behavior or 'preferBuiltins: true' to disable t his warning ⚠ 'path' is imported by commonjs-external:path, but could not be resol ved – treating it as an external dependency https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as- external-dependency ⚠ 'fs' is imported by commonjs-external:fs, but could not be resolved – treating it as an external dependency https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as- external-dependency ⚠ 'module' is imported by commonjs-external:module, but could not be r esolved – treating it as an external dependency https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as- external-dependency ⚠ 'default' is not exported by 'node_modules/simple-dom/lib/simple-dom .js' https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exporte d-by-module commonjs-proxy:/Users/morita1/Desktop/riot_timetable/node_modules/simple- dom/lib/simple-dom.js (1:150) 1: import * as simpleDom from "/Users/morita1/Desktop/riot_timetable/node _modules/simple-dom/lib/simple-dom.js"; export default ( simpleDom && sim pleDom['default'] ) || simpleDom; ⚠ 'default' is not exported by 'node_modules/simple-html-tokenizer/lib /simple-html-tokenizer/index.js' https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exporte d-by-module commonjs-proxy:/Users/morita1/Desktop/riot_timetable/node_modules/simple- html-tokenizer/lib/simple-html-tokenizer/index.js (1:166) 1: import * as index from "/Users/morita1/Desktop/riot_timetable/node_mod ules/simple-html-tokenizer/lib/simple-html-tokenizer/index.js"; export de fault ( index && index['default'] ) || index; ^ ⚠ Creating a browser bundle that depends on Node.js built-in module (' path'). You might need to include https://www.npmjs.com/package/rollup-pl ugin-node-builtins ⚠ No name was provided for external module 'path' in options.globals – guessing 'path' ⚠ No name was provided for external module 'fs' in options.globals – g uessing 'fs' ⚠ No name was provided for external module 'module' in options.globals – guessing 'module$1'

###該当のソースコード

src/tags/app.tag

1<app> 2 <div>hello world!</div> 3</app>

src/main.js

1import 'babel-polyfill' 2import 'es6-promise' 3import 'fetch-polyfill' 4import riot from 'riot' 5import route from 'riot-route' 6import Router from 'riot-router' 7import './tags/app.tag' 8window.riot = riot; 9window.obs = riot.observable() 10window.route = route; 11document.addEventListener('DOMContentLoaded', () => { 12 route.start(true) 13 riot.mount('*') 14})

rollup.config.js

1import riot from 'rollup-plugin-riot' 2import nodeResolve from 'rollup-plugin-node-resolve' 3import commonjs from 'rollup-plugin-commonjs' 4// import buble from 'rollup-plugin-buble' 5import postcss from 'postcss' 6import postcssCssnext from 'postcss-cssnext' 7import babel from 'rollup-plugin-babel' 8// import path from 'path' 9// import moment from 'moment'; 10// import inject from 'rollup-plugin-inject'; 11import replace from 'rollup-plugin-replace' 12 13export default { 14 entry: 'src/main.js', 15 dest: 'dist/bundle.js', 16 plugins: [ 17 replace({ 18 'process.env.NODE_ENV': JSON.stringify('production') 19 }), 20 riot({ 21 style: 'cssnext', 22 parsers: { 23 css: { 24 cssnext 25 } 26 } 27 }), 28 nodeResolve({ 29 jsnext: true 30 }), 31 commonjs(), 32 babel() 33 ], 34 format: 'iife' 35} 36 37/** 38 * Transforms new CSS specs into more compatible CSS 39 */ 40function cssnext(tagName, css) { 41 // A small hack: it passes :scope as :root to PostCSS. 42 // This make it easy to use css variables inside tags. 43 css = css.replace(/:scope/g, ':root') 44 css = postcss([postcssCssnext]).process(css).css 45 css = css.replace(/:root/g, ':scope') 46 return css 47}

###補足情報(言語/FW/ツール等のバージョンなど)
"dependencies": {
"es6-promise": "^4.0.5",
"fetch-polyfill": "^0.8.2",
"immutable": "^3.8.1",
"marked": "^0.3.6",
"object-assign": "^4.1.1",
"path": "^0.12.7",
"postcss": "^5.2.11",
"redux": "^3.6.0",
"redux-logger": "^2.7.4",
"redux-saga": "^0.14.3",
"reselect": "^2.5.4",
"riot": "^3.1.0",
"riot-redux": "^0.3.3",
"riot-redux-mixin": "^1.0.0",
"riot-route": "^2.5.0",
"riot-router": "^0.8.1"
},
"devDependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-polyfill": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-es2015-riot": "^1.1.0",
"babel-register": "^6.22.0",
"browser-sync": "^2.18.6",
"chokidar-cli": "^1.2.0",
"moment": "^2.17.1",
"path": "^0.12.7",
"postcss": "^5.2.9",
"postcss-cssnext": "^2.9.0",
"rollup": "^0.41.1",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-includepaths": "^0.1.8",
"rollup-plugin-inject": "^2.0.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-riot": "^1.1.0"
}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問