未找到模块 (Riot),但 riotjs 已安装并正常工作

Module (Riot) not Found, yet riotjs is installed and working

我确实在全球范围内安装了 riot 和 riot-cli。我已经从命令行测试了两者。事实上,我还有另一个项目,riot 正在正常观看和预编译。

这是一个 webpack 设置,这是错误:

ERROR in ./src/index.js
Module not found: Error: Can't resolve 'riot' in 
'c:\Users\...\www\riot\src'
@ ./src/index.js 3:11-26
@ multi (webpack)-dev-server/client?http... ./src/index.js

ERROR in ./src/index.js
Module not found: Error: Can't resolve '.tags/sample-output.tag' in 'c:\Users\...\www\riot\src'
@ ./src/index.js 4:0-34
@ multi (webpack)-dev-server/client?http... ./src/index.js
webpack: Failed to compile. 

这是索引文件:

var riot = require('riot')
require('.tags/sample-output.tag')

document.addEventlistner('DOMContentLoaded', function(){
    riot.mount('sample-output')
})

这里是 webpack.config

var path = require('path')

module.exports = {
    entry: './src/index.js',
    output:{
        path:__dirname,
        filename:'bundle.js'
    },
    module:{
        loaders:[
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/,
                query:{
                    presets:['es2015']
                }
            },
            {
                test: /\.tag$/,
                loader: 'tag',
                exclude: /node_modules/
            }
        ]
    }
}

(已解决)我找到了答案。

基本上我调用了我的项目文件夹 'riot',然后当我使用 -y 标志 运行 npm init -y 时(因为我很懒)。

它当然将我的项目命名为“riot”!这就是问题的根源。

有关详细信息,请参阅:http://thisdavej.com/node-newbie-error-npm-refusing-to-install-package-as-a-dependency-of-itself/